| 436 | } |
| 437 | |
| 438 | function stripBasePathFromUrl(rawUrl, basePath) { |
| 439 | if (basePath === "/") return rawUrl; |
| 440 | |
| 441 | const [rawPath = "/", ...rest] = (rawUrl || "/").split("?"); |
| 442 | const suffix = rawPath.slice(basePath.length) || "/"; |
| 443 | const path = suffix.startsWith("/") ? suffix : `/${suffix}`; |
| 444 | return rest.length > 0 ? `${path}?${rest.join("?")}` : path; |
| 445 | } |
| 446 | |
| 447 | function redirectToMountedPath(req, res, urlPath, basePath) { |
| 448 | if (basePath === "/" || !isGetOrHead(req) || looksLikeAssetRequest(urlPath)) { |