Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #298 from sveltejs/gh-296
Browse files Browse the repository at this point in the history
fix req.baseUrl synthesis
  • Loading branch information
Rich-Harris authored Jun 27, 2018
2 parents 31110a5 + 087356f commit b9a1201
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,13 @@ export default function middleware({ App, routes, store }: {
const middleware = compose_handlers([
(req: Req, res: ServerResponse, next: () => void) => {
if (req.baseUrl === undefined) {
req.baseUrl = req.originalUrl
? req.originalUrl.slice(0, -req.url.length)
let { originalUrl } = req;
if (req.url === '/' && originalUrl[originalUrl.length - 1] !== '/') {
originalUrl += '/';
}

req.baseUrl = originalUrl
? originalUrl.slice(0, -req.url.length)
: '';
}

Expand Down

0 comments on commit b9a1201

Please sign in to comment.