Package io.quarkus.deployment.util
Class UriNormalizationUtil
- java.lang.Object
-
- io.quarkus.deployment.util.UriNormalizationUtil
-
public class UriNormalizationUtil extends Object
Common URI path resolution
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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
toURI(String path, boolean trailingSlash)
Create a URI path from a string.
-
-
-
Method Detail
-
toURI
public static URI toURI(String path, boolean trailingSlash)
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
public static URI normalizeWithBase(URI base, String segment, boolean trailingSlash)
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- {@code normalizeWithBase(new URI("/prefix/"), "example", true)} will return a URI with path {@literal /prefix/example/}
- {@code normalizeWithBase(new URI("/prefix/"), "example", false)} will return a URI with an empty path {@literal /prefix/example}
- {@code normalizeWithBase(new URI("/prefix/"), "/example", true)} will return a URI with path {@literal /example/}
- {@code normalizeWithBase(new URI("/prefix/"), "/example", false)} will return a URI with an empty path {@literal /example}
- {@code normalizeWithBase(new URI("foo/"), "example", true)} will return a URI with path {@literal foo/example/}
- {@code normalizeWithBase(new URI("foo/"), "example", false)} will return a URI with an empty path {@literal foo/example}
- {@code normalizeWithBase(new URI("foo/"), "/example", true)} will return a URI with path {@literal /example/}
- {@code normalizeWithBase(new URI("foo/"), "/example", false)} will return a URI with an empty path {@literal /example}
- Parameters:
base
- URI to resolve relative paths. UsetoURI(String, boolean)
to construct this parameter.segment
- Relative or absolute pathtrailingSlash
- true if resulting URI must end with a '/'- Throws:
IllegalArgumentException
- if the path contains invalid characters or path segments.
-
-