Package com.vaadin.flow.router.internal
Class PathUtil
java.lang.Object
com.vaadin.flow.router.internal.PathUtil
- All Implemented Interfaces:
Serializable
Utility class which contains various methods for parsing a route url into
segments.
For internal use only. May be renamed or removed in a future release.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringJoin the segments into a url path.static StringJoin the segments into a url path.getSegmentsList(String path) Returns an unmodifiable list containing the segments of the specified path.Returns an unmodifiable list containing the URL-decoded segments of the specified path.static StringTrim the path by removing any leading and trailing whitespaces and slashes.static StringtrimSegmentsString(String path) Trim the path by removing any leading and trailing whitespaces and trailing slashes.
-
Constructor Details
-
PathUtil
public PathUtil()
-
-
Method Details
-
getSegmentsList
Returns an unmodifiable list containing the segments of the specified path.- Parameters:
path- url path to split into segments. The path may also start with a slash `/` but it may not contain the url protocol.- Returns:
- a List containing the segments of the path.
-
getSegmentsListWithDecoding
Returns an unmodifiable list containing the URL-decoded segments of the specified path. Each segment is decoded usingUrlUtil.decodeURIComponent(String), which properly handles percent-encoded characters including slashes (%2F), spaces (%20), and other special characters.This method is designed for processing paths where individual segments may contain URL-encoded data that should be preserved after decoding. For example, a path segment containing
%2Fwill be decoded to/, but this slash will not be treated as a path separator.- Parameters:
path- url path to split into segments and decode. The path may also start with a slash `/` but it may not contain the url protocol.- Returns:
- a List containing the decoded segments of the path.
-
getPath
Join the segments into a url path.- Parameters:
segments- path segments.- Returns:
- path form from input segments.
-
getPath
Join the segments into a url path.- Parameters:
basePath- path prefix.segments- path segments following the prefix.- Returns:
- the path form by concatenating basePath and segments.
-
trimPath
Trim the path by removing any leading and trailing whitespaces and slashes.- Parameters:
path- url path to trim.- Returns:
- a String representing the input path without any leading and trailing whitespaces and slashes.
-
trimSegmentsString
Trim the path by removing any leading and trailing whitespaces and trailing slashes.- Parameters:
path- url path to trim, not null- Returns:
- a String representing the input path without any leading and trailing whitespaces or trailing slash.
-