RegexURLPattern
public class RegexURLPattern : URLPattern
A URL Pattern matcher that uses Grails-style matching to extract named parameter values from the path
and use them like query parameters. The following syntax is supported, per path component, so that
macros are not able to span components (i.e. path components cannot contain or match /
):
$(paramName)
— e.g.something$(param1)
,$(param1)something
,something$(param1)something
. The text whereparam1
is in the path is extracted into the query parameters with the keyparam1
*
— a wildcard that represents 1 or moreany
characters, e.g.something*
,*something
,*
**
— a wildcard that matches everything after it in the URL path. It is not valid to have**
anywhere except the final path component
/store/categories/grindcore --> parameters [:]
/store/$(category)/grindcore --> parameters ["category":x]
/store/$(category)/items/$(sku) --> parameters ["category":x, "sku": y]
/store/$(category)/items/** --> parameters ["category":x] (** matches any suffix)
/store/$(category)/*/whatever --> parameters ["category":x] (* matches any component, not captured)
/store/$(category)/*/whatever?var1=a --> parameters ["category":x, "var1":"a"]
/store/*/whatever?var1=a --> parameters ["var1":"a"]
/store/*/**?var1=a --> parameters ["var1":"a"]
/** --> parameters [:]
-
Declaration
Swift
public let urlPattern: String
-
Declaration
Swift
public var isValidForLinkCreation: Bool { get }
-
Declaration
Swift
public func match(path: String) -> [String : String]?
-
Declaration
Swift
public func buildPath(with parameters: [String : String]?) -> String?