Regularize page and server routes

Treats both page and server routes similarly in regards to indexes.

It's a (somewhat) breaking change: server routes will accept trailing
slashes to match page routes behavior, but only if there's no extension.

We still need a stronger support for dealing with different clean urls
rules.
This commit is contained in:
mrkishi
2019-05-05 03:40:58 -03:00
parent f886a12bd7
commit 54e92c3b99
4 changed files with 52 additions and 44 deletions

View File

@@ -101,7 +101,11 @@ export function select_target(url: URL): Target {
if (url.origin !== location.origin) return null;
if (!url.pathname.startsWith(initial_data.baseUrl)) return null;
const path = url.pathname.slice(initial_data.baseUrl.length);
let path = url.pathname.slice(initial_data.baseUrl.length);
if (path === '') {
path = '/';
}
// avoid accidental clashes between server routes and page routes
if (ignore.some(pattern => pattern.test(path))) return;