Skip to content

Function: pathMatch()

pathMatch(input, path): boolean

Convenience wrapper over UrlBuilder.pathMatches: coerce input via urlBuilder and test its pathname against path. Returns false for input that can’t be parsed into a URL.

UrlLike

string

boolean

pathMatch("/api/cool?q=1", "/api"); // true
pathMatch("/apicool", "/api"); // false
pathMatch("https://host/api", "/api"); // true
pathMatch(request, "/api/v2"); // fetch Request