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