Home > @plasmicapp/loader-react > matchesPagePath

matchesPagePath() function

Check if lookup resolves to pagePath. If it's a match, return an object containing path params; otherwise, return false.

For example, - matchesPagePath("/hello/[name]", "/hello/world") -> {params: {name: "world"}} - matchesPagePath("/hello/[name]", "/") -> false - matchesPagePath("/hello/[...catchall]", "/hello/a/b/c") -> {params: {catchall: ["a", "b", "c"]}} - matchesPagePath("/", "") -> {params: {}}

Signature:

export declare function matchesPagePath(pagePath: string, lookup: string): {
    params: Record<string, string | string[]>;
} | false;

Parameters

Parameter Type Description
pagePath string
lookup string

Returns:

{ params: Record<string, string | string[]>; } | false