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