Compare commits

...

3 Commits

Author SHA1 Message Date
Rich Harris
f821c19528 -> v0.13.6 2018-06-27 17:20:45 -04:00
Rich Harris
b9a120164a Merge pull request #298 from sveltejs/gh-296
fix req.baseUrl synthesis
2018-06-27 17:19:55 -04:00
Rich Harris
087356f781 fix req.baseUrl synthesis 2018-06-27 16:57:04 -04:00
3 changed files with 12 additions and 3 deletions

View File

@@ -1,5 +1,9 @@
# sapper changelog
## 0.13.6
* Fix `baseUrl` synthesis ([#296](https://github.com/sveltejs/sapper/issues/296))
## 0.13.5
* Fix handling of fatal errors ([#289](https://github.com/sveltejs/sapper/issues/289))

View File

@@ -1,6 +1,6 @@
{
"name": "sapper",
"version": "0.13.5",
"version": "0.13.6",
"description": "Military-grade apps, engineered by Svelte",
"main": "dist/middleware.ts.js",
"bin": {

View File

@@ -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)
: '';
}