{"code":"/**\r\n * Borrowed from React Router\r\n * https://github.com/ReactTraining/react-router/blob/master/packages/react-router/modules/matchPath.js\r\n * All credit goes the the React Router maintainers\r\n */\r\nconst pathToRegexp = require('path-to-regexp');\r\nconst patternCache = {};\r\nconst cacheLimit = 10000;\r\nlet cacheCount = 0;\r\nconst compilePath = (pattern, options) => {\r\n    const p = pattern;\r\n    const cacheKey = `${options.end}${options.strict}${options.sensitive}`;\r\n    const cache = patternCache[cacheKey] || (patternCache[cacheKey] = {});\r\n    if (cache[p]) {\r\n        return cache[p];\r\n    }\r\n    const keys = [];\r\n    const re = pathToRegexp(pattern, keys, options);\r\n    const compiledPattern = { re, keys };\r\n    if (cacheCount < cacheLimit) {\r\n        cache[p] = compiledPattern;\r\n        cacheCount += 1;\r\n    }\r\n    return compiledPattern;\r\n};\r\n/**\r\n * Public API for matching a URL pathname to a path pattern.\r\n */\r\nconst matchPath = (pathname, options = {}) => {\r\n    const o = (typeof options === 'string') ? { path: options } : options;\r\n    const { path = '/', exact = false, strict = false, sensitive = false } = o;\r\n    const { re, keys } = compilePath(path, { end: exact, strict, sensitive });\r\n    const match = re.exec(pathname);\r\n    if (!match)\r\n        return null;\r\n    const [url, ...values] = match;\r\n    const isExact = pathname === url;\r\n    if (exact && !isExact)\r\n        return null;\r\n    return {\r\n        path,\r\n        url: path === '/' && url === '' ? '/' : url,\r\n        isExact,\r\n        params: keys.reduce((memo, key, index) => {\r\n            memo[key.name] = values[index];\r\n            return memo;\r\n        }, {})\r\n    };\r\n};\r\nexport default matchPath;\r\n","dts":{"name":"/Users/tristanmatthias/projects/origami/zen/lib/Path.d.ts","text":"export interface MatchPathOptions {\r\n    path?: string;\r\n    exact?: boolean;\r\n    strict?: boolean;\r\n    sensitive?: boolean;\r\n}\r\nexport interface MatchResults {\r\n    path: string;\r\n    url: string;\r\n    isExact: boolean;\r\n    params: MatchResultsParams;\r\n}\r\nexport interface MatchResultsParams {\r\n    [key: string]: any;\r\n}\r\n/**\r\n * Public API for matching a URL pathname to a path pattern.\r\n */\r\ndeclare const matchPath: (pathname: string, options?: string | MatchPathOptions) => MatchResults | null;\r\nexport default matchPath;\r\n"}}
