RouteSegment
Module: parch
Represents a single route segment, providing a consistent output segment regardless of trailing/leading slashes
Table of Contents
- Methods
- Properties
Constructor
RouteSegment
(
-
segment
Parameters:
-
segment
StringA single route segment
Example:
new RouteSegment("/foo"); => { path: "/foo", segment: "/foo" }
new RouteSegment("foo"); => { path: "/foo", segment: "foo" }
new RouteSegment("/foo/"); => { path: "/foo", segment: "/foo/" }
new RouteSegment("foo/"); => { path: "/foo", segment: "foo/" }
Methods
Builds a consistent path segment, regardless of slashes
Returns:
String:
path segment
Determines if a path segment contains a leading slash /
Returns:
Example:
new RouteSegment("foo").hasLeadingSlash(); => false
new RouteSegment("foo/").hasLeadingSlash(); => false
new RouteSegment("/foo/").hasLeadingSlash(); => true
new RouteSegment("/foo").hasLeadingSlash(); => true
Determines if a path segment contains a trailing slash /
Returns:
Example:
new RouteSegment("foo").hasTrailingSlash(); => false
new RouteSegment("/foo").hasTrailingSlash(); => false
new RouteSegment("/foo/").hasTrailingSlash(); => true
new RouteSegment("foo/").hasTrailingSlash(); => true