package io.ljunggren.url.utils;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;

public class UrlUtils {
    
    public static String encode(String string) throws UnsupportedEncodingException {
        if (string == null) {
            return null;
        }
        return URLEncoder.encode(string, StandardCharsets.UTF_8.toString());
    }

    public static String decode(String string) throws UnsupportedEncodingException {
        if (string == null) {
            return null;
        }
        return URLDecoder.decode(string, StandardCharsets.UTF_8.toString());
    }

}
