@zubra/router 6.0.3 → 6.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/answers.js +3 -1
package/package.json
CHANGED
package/src/answers.js
CHANGED
|
@@ -16,7 +16,9 @@ export function checkedLocation({ location, external }, url) {
|
|
|
16
16
|
}
|
|
17
17
|
if (!['http:', 'https:'].includes(target.protocol)) throw new RouteError(`redirect() to a ${target.protocol} URL is refused`);
|
|
18
18
|
if (target.origin !== url.origin && !external) throw new RouteError(`redirect() to ${target.origin}, another site: say redirect(to, { external: true }) if that's meant`);
|
|
19
|
-
|
|
19
|
+
// A path on this site that begins `//` (from `https://site//evil.example`, `.//evil.example` or
|
|
20
|
+
// `..//evil.example`) is protocol-relative in a Location header: one slash keeps it here.
|
|
21
|
+
return target.origin === url.origin ? '/' + (target.pathname + target.search + target.hash).replace(/^[/\\]+/, '') : target.href;
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
/** `return notFound()`: the path has nothing behind it (no such farm). The response is a 404. */
|