Fix website's third-party link results in error in Chrome
In Navigation API supported browsers, clicking `third-party-license.txt`
leads to an error page due to the navigation handler (mis)intercepts
the text file link as a prepped page link.
return;
}
+ const dest = new URL(ev.destination.url);
+ if (!dest.pathname.endsWith("/")) {
+ return;
+ }
+ ev.intercept({
async handler() {
- const r = await route(new URL(ev.destination.url).pathname);
+ const r = await route(dest.pathname);
// NOTE: Chrome seems to have a bug that it can't scroll at all on Navigation API.
// I don't know what causes this.