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 where param1 is in the path is extracted into the query parameters with the key param1
  • * — a wildcard that represents 1 or more any 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 [:]