one
Version:
One is a React framework for web, iOS, and Android apps.
1 lines • 2.95 kB
Source Map (JSON)
{"version":3,"file":"path.js","names":[],"sources":["esm/router/path.js"],"sourcesContent":["import { stripBaseUrl } from \"../fork/getStateFromPath-mods\";\nfunction stripPathSuffix(path) {\n const queryIndex = path.indexOf(\"?\");\n const hashIndex = path.indexOf(\"#\");\n let end = path.length;\n if (queryIndex >= 0) end = Math.min(end, queryIndex);\n if (hashIndex >= 0) end = Math.min(end, hashIndex);\n return path.slice(0, end);\n}\nfunction stripTrailingSlash(pathname) {\n return pathname.length > 1 && pathname.endsWith(\"/\") ? pathname.slice(0, -1) : pathname;\n}\nfunction normalizeRoutePathname(pathname) {\n return stripTrailingSlash(stripBaseUrl(stripPathSuffix(pathname)));\n}\nfunction hasLostDynamicSegment(path) {\n return stripPathSuffix(path).split(\"/\").includes(\"undefined\");\n}\nfunction getSafeWindowPathname() {\n if (typeof window === \"undefined\" || !window.location || typeof window.location.pathname !== \"string\") {\n return void 0;\n }\n return window.location.pathname;\n}\nfunction getSafeWindowPath() {\n const pathname = getSafeWindowPathname();\n if (pathname === void 0) return void 0;\n return pathname + (window.location.search || \"\");\n}\nfunction getPathWithRecoveredDynamicSegment(paths, fallbackPath = getSafeWindowPath()) {\n for (const path of paths) {\n if (path !== void 0 && !hasLostDynamicSegment(path)) {\n return path;\n }\n }\n return fallbackPath;\n}\nfunction getPathnameWithRecoveredDynamicSegment(pathname, fallbackPath = getSafeWindowPath()) {\n return normalizeRoutePathname(\n getPathWithRecoveredDynamicSegment([pathname], fallbackPath) ?? pathname\n );\n}\nexport {\n getPathWithRecoveredDynamicSegment,\n getPathnameWithRecoveredDynamicSegment,\n getSafeWindowPath,\n getSafeWindowPathname,\n hasLostDynamicSegment,\n normalizeRoutePathname,\n stripPathSuffix,\n stripTrailingSlash\n};\n//# sourceMappingURL=path.js.map\n"],"mappings":";;;AACA,SAAS,gBAAgB,MAAM;CAC7B,MAAM,aAAa,KAAK,QAAQ,GAAG;CACnC,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