Spaces:
Sleeping
Sleeping
Download node_modules/next/dist/shared/lib/router/utils/path-match.js from imspsycho/ling-open-studio: direct link, hf CLI and curl.
- Browser
- Download file 1.85 kB
-
https://huggingface.co/spaces/imspsycho/ling-open-studio/resolve/main/node_modules/next/dist/shared/lib/router/utils/path-match.js
- Command line
-
hf download hf://spaces/imspsycho/ling-open-studio/node_modules/next/dist/shared/lib/router/utils/path-match.js
-
curl -L -o path-match.js https://huggingface.co/spaces/imspsycho/ling-open-studio/resolve/main/node_modules/next/dist/shared/lib/router/utils/path-match.js
1.85 kB
| ; | |
| Object.defineProperty(exports, "__esModule", { | |
| value: true | |
| }); | |
| Object.defineProperty(exports, "getPathMatch", { | |
| enumerable: true, | |
| get: function() { | |
| return getPathMatch; | |
| } | |
| }); | |
| const _pathtoregexp = require("next/dist/compiled/path-to-regexp"); | |
| function getPathMatch(path, options) { | |
| const keys = []; | |
| const regexp = (0, _pathtoregexp.pathToRegexp)(path, keys, { | |
| delimiter: '/', | |
| sensitive: typeof options?.sensitive === 'boolean' ? options.sensitive : false, | |
| strict: options?.strict | |
| }); | |
| const matcher = (0, _pathtoregexp.regexpToFunction)(options?.regexModifier ? new RegExp(options.regexModifier(regexp.source), regexp.flags) : regexp, keys); | |
| /** | |
| * A matcher function that will check if a given pathname matches the path | |
| * given in the builder function. When the path does not match it will return | |
| * `false` but if it does it will return an object with the matched params | |
| * merged with the params provided in the second argument. | |
| */ return (pathname, params)=>{ | |
| // If no pathname is provided it's not a match. | |
| if (typeof pathname !== 'string') return false; | |
| const match = matcher(pathname); | |
| // If the path did not match `false` will be returned. | |
| if (!match) return false; | |
| /** | |
| * If unnamed params are not allowed they must be removed from | |
| * the matched parameters. path-to-regexp uses "string" for named and | |
| * "number" for unnamed parameters. | |
| */ if (options?.removeUnnamedParams) { | |
| for (const key of keys){ | |
| if (typeof key.name === 'number') { | |
| delete match.params[key.name]; | |
| } | |
| } | |
| } | |
| return { | |
| ...params, | |
| ...match.params | |
| }; | |
| }; | |
| } | |
| //# sourceMappingURL=path-match.js.map |