Java Code Examples for io.undertow.util.URLUtils#normalizeSlashes()

The following examples show how to use io.undertow.util.URLUtils#normalizeSlashes() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: lams   File: VirtualHost.java    License: GNU General Public License v2.0 6 votes vote down vote up
public synchronized void removeContext(final String path, final String jvmRoute, final Context context) {
    if (path == null || path.isEmpty()) {
        throw UndertowMessages.MESSAGES.pathMustBeSpecified();
    }

    final String normalizedPath = URLUtils.normalizeSlashes(path);
    if (STRING_PATH_SEPARATOR.equals(normalizedPath)) {
        defaultHandler.contexts.remove(jvmRoute, context);
    }

    final HostEntry hostEntry = contexts.get(normalizedPath);
    if (hostEntry != null) {
        if (hostEntry.contexts.remove(jvmRoute, context)) {
            if (hostEntry.contexts.isEmpty()) {
                contexts.remove(normalizedPath);
                buildLengths();
            }
        }
    }
}
 
Example 2
private String getBasePath(URI httpURI) {
    String path = httpURI.getPath();
    if (path.contains(REST_PATH_PLACEHOLDER)) {
        path = PathTemplate.create(path).getBase();
    }
    return URLUtils.normalizeSlashes(path);
}
 
Example 3
private String getRelativePath(URI httpURI, boolean matchOnUriPrefix) {
    String path = httpURI.getPath();
    String contextPath = getContextPath(httpURI);
    String normalizedPath = URLUtils.normalizeSlashes(path.substring(contextPath.length()));
    if (matchOnUriPrefix) {
        normalizedPath += "*";
    }
    return normalizedPath;
}