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

nl.pvanassen.steam.store.helper.UrlNameHelper Maven / Gradle / Ivy

Go to download

A Java API to access the Steam community market through the HTTP interface. This may be against the TOS so be careful using it!

There is a newer version: 3.0.8
Show newest version
package nl.pvanassen.steam.store.helper;

import nl.pvanassen.steam.error.SteamException;
import org.slf4j.LoggerFactory;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;

/**
 * URL name helper to return a uniform url name
 *
 * @author Paul van Assen
 */
public final class UrlNameHelper {
    /**
     * Make sure urlName is uniform
     * 
     * @param urlName Url name, encoded or not.
     * @return Uniform url
     */
    public static String getUrlName(String urlName) {
        try {
            String decodedUrlName = URLDecoder.decode(urlName, "UTF-8");
            return URLEncoder.encode(decodedUrlName, "UTF-8").replace("+", "%20");
        }
        catch (UnsupportedEncodingException e) {
            throw new SteamException("Encoding not present", e);
        }
        catch (IllegalArgumentException e) {
            LoggerFactory.getLogger(UrlNameHelper.class).error("Error getting url name for '" + urlName + "'", e);
            throw new SteamException("Error getting url name for '" + urlName + "'", e);
        }
    }

    private UrlNameHelper() {
        super();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy