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

org.mockserver.url.URLParser Maven / Gradle / Ivy

There is a newer version: 5.15.0
Show newest version
package org.mockserver.url;

/**
 * @author jamesdbloom
 */
public class URLParser {

    private static final String schemeRegex = "(https?:)?//.*";
    private static final String schemeHostAndPortRegex = "(https?:)?//([A-z0-9-_.:]*@)?[A-z0-9-_.]*(:[0-9]*)?";

    public static boolean isFullUrl(String uri) {
        return uri != null && uri.matches(schemeRegex);
    }

    public static String returnPath(String path) {
        if (URLParser.isFullUrl(path)) {
            return path.replaceAll(schemeHostAndPortRegex, "");
        } else {
            return path;
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy