(req: express.Request, query: qs.ParsedQs, to: string)
| 172 | * Redirect path is relative to `/${to}`. |
| 173 | */ |
| 174 | export 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 |
no test coverage detected