| 566 | } |
| 567 | |
| 568 | function stripBasePathFromUrl(rawUrl, basePath) { |
| 569 | if (basePath === "/") return rawUrl; |
| 570 | |
| 571 | const [rawPath = "/", ...rest] = (rawUrl || "/").split("?"); |
| 572 | const suffix = rawPath.slice(basePath.length) || "/"; |
| 573 | const path = suffix.startsWith("/") ? suffix : `/${suffix}`; |
| 574 | return rest.length > 0 ? `${path}?${rest.join("?")}` : path; |
| 575 | } |
| 576 | |
| 577 | function redirectToMountedPath(req, res, urlPath, basePath) { |
| 578 | if (basePath === "/" || !isGetOrHead(req) || looksLikeAssetRequest(urlPath)) { |