MCPcopy Index your code
hub / github.com/coder/code-server / constructRedirectPath

Function constructRedirectPath

src/node/http.ts:174–181  ·  view source on GitHub ↗
(req: express.Request, query: qs.ParsedQs, to: string)

Source from the content-addressed store, hash-verified

172 * Redirect path is relative to `/${to}`.
173 */
174export const constructRedirectPath = (req: express.Request, query: qs.ParsedQs, to: string): string => {
175 const relativePath = normalize(`${relativeRoot(req.originalUrl)}/${to}`, true)
176 // %2f or %2F are both equalivent to an encoded slash /
177 const queryString = qs.stringify(query).replace(/%2[fF]/g, "/")
178 const redirectPath = `${relativePath}${queryString ? `?${queryString}` : ""}`
179
180 return redirectPath
181}
182
183/**
184 * Redirect relatively to `/${to}`. Query variables on the current URI will be

Callers 1

redirectFunction · 0.85

Calls 2

normalizeFunction · 0.90
relativeRootFunction · 0.85

Tested by

no test coverage detected