All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.deploygate.gradle.plugins.internal.utils.UrlUtils Maven / Gradle / Ivy

Go to download

This is the DeployGate plugin for the Gradle. You can build and deploy your apps to DeployGate by running a single task.

There is a newer version: 2.9.0
Show newest version
package com.deploygate.gradle.plugins.internal.utils;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.jetbrains.annotations.NotNull;

public final class UrlUtils {
    private UrlUtils() {}

    @NotNull public static Map parseQueryString(@NotNull String s) {
        if (StringUtils.isNullOrEmpty(s)) {
            return Collections.emptyMap();
        }

        Map params = new HashMap<>();

        for (final String part : s.split("&")) {
            if (part.isEmpty()) {
                continue;
            }

            String[] kv = part.split("=", 2);

            try {
                params.put(URLDecoder.decode(kv[0], "UTF-8"), URLDecoder.decode(kv[1], "UTF-8"));
            } catch (UnsupportedEncodingException never) {
                throw new RuntimeException(never);
            }
        }

        return params;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy