Package io.quarkus.deployment.util
Class UriNormalizationUtil
java.lang.Object
io.quarkus.deployment.util.UriNormalizationUtil
Common URI path resolution
-
Method Summary
Modifier and TypeMethodDescriptionstatic URI
normalizeWithBase
(URI base, String segment, boolean trailingSlash) Resolve a string path against a URI base.static String
relativize
(String rootPath, String leafPath) static URI
Create a URI path from a string.
-
Method Details
-
toURI
Create a URI path from a string. The specified path can not contain relative .. segments or % characters.Examples:
toUri("/", true)
will return a URI with path /toUri("/", false)
will return a URI with an empty path /toUri("./", true)
will return a URI with path /toUri("./", false)
will return a URI with an empty path /toUri("foo/", true)
will return a URI with path foo/toUri("foo/", false)
will return a URI with an empty path foo
- Parameters:
path
- String to convert into a URItrailingSlash
- true if resulting URI must end with a '/'- Throws:
IllegalArgumentException
- if the path contains invalid characters or path segments.
-
normalizeWithBase
Resolve a string path against a URI base. The specified path can not contain relative .. segments or % characters. Relative paths will be resolved against the specified base URI. Absolute paths will be normalized and returned.Examples:
normalizeWithBase(new URI("/"), "example", true)
will return a URI with path /example/normalizeWithBase(new URI("/"), "example", false)
will return a URI with an empty path /examplenormalizeWithBase(new URI("/"), "/example", true)
will return a URI with path /example/normalizeWithBase(new URI("/"), "/example", false)
will return a URI with an empty {@literal /example</li> <li>{@code normalizeWithBase(new URI("/prefix/"), "example", true)} will return a URI with path {@literal /prefix/example/}</li> <li>{@code normalizeWithBase(new URI("/prefix/"), "example", false)} will return a URI with an empty path {@literal /prefix/example}</li> <li>{@code normalizeWithBase(new URI("/prefix/"), "/example", true)} will return a URI with path {@literal /example/}</li> <li>{@code normalizeWithBase(new URI("/prefix/"), "/example", false)} will return a URI with an empty path {@literal /example}</li> <li>{@code normalizeWithBase(new URI("foo/"), "example", true)} will return a URI with path {@literal foo/example/}</li> <li>{@code normalizeWithBase(new URI("foo/"), "example", false)} will return a URI with an empty path {@literal foo/example}</li> <li>{@code normalizeWithBase(new URI("foo/"), "/example", true)} will return a URI with path {@literal /example/}</li> <li>{@code normalizeWithBase(new URI("foo/"), "/example", false)} will return a URI with an empty path {@literal /example}</li> </ul> @param base URI to resolve relative paths. Use {@link #toURI(String, boolean)} to construct this parameter. @param segment Relative or absolute path @param trailingSlash true if resulting URI must end with a '/' @throws IllegalArgumentException if the path contains invalid characters or path segments.
-
relativize
-