MCPcopy Index your code
hub / github.com/react-static/react-static / getRoutePath

Function getRoutePath

packages/react-static/src/browser/utils/index.js:64–90  ·  view source on GitHub ↗
(routePath)

Source from the content-addressed store, hash-verified

62// RoutePaths do not have query params, basePaths, and should
63// resemble the same string as passed in the static.config.js routes
64export function getRoutePath(routePath) {
65 // Detect falsey paths and the root path
66 if (
67 !routePath ||
68 routePath === '/' ||
69 routePath === process.env.REACT_STATIC_BASE_PATH
70 ) {
71 return '/'
72 }
73
74 // Remove origin, hashes, and query params
75 if (typeof document !== 'undefined') {
76 routePath = routePath.replace(window.location.origin, '')
77 routePath = routePath.replace(/#.*/, '')
78 routePath = routePath.replace(/\?.*/, '')
79 }
80
81 // Be sure to remove the base path
82 if (process.env.REACT_STATIC_BASE_PATH) {
83 routePath = routePath.replace(
84 new RegExp(`^\\/?${process.env.REACT_STATIC_BASE_PATH}(\\/|$)`),
85 ''
86 )
87 }
88 routePath = routePath || '/'
89 return pathJoin(routePath)
90}
91
92export function getCurrentRoutePath() {
93 // If in the browser, use the window

Callers 9

registerTemplateForPathFunction · 0.90
getRouteInfoFunction · 0.90
prefetchTemplateFunction · 0.90
prefetchFunction · 0.90
useRoutePathFunction · 0.90
usePrefetchFunction · 0.90
normalizeRouteFunction · 0.90
getCurrentRoutePathFunction · 0.85
shared.test.jsFile · 0.85

Calls 1

pathJoinFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…