fix: handle absolute relative paths

This commit is contained in:
Derrick Hammer 2023-11-18 09:07:31 -05:00
parent eb6c2d94cc
commit c7f3ffa2c1
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 2 additions and 2 deletions

View File

@ -33,7 +33,7 @@ export default class URLRewriteFilter implements ContentFilter {
urlValue.startsWith("http") || urlValue.startsWith("http") ||
(urlValue.startsWith("//") && isICANN(urlValue)); (urlValue.startsWith("//") && isICANN(urlValue));
if (!isExternal || !isICANN(urlValue)) { if (!isExternal || !isICANN(urlValue)) {
if (!isExternal) { if (!isExternal && !urlValue.startsWith("/")) {
//@ts-ignore //@ts-ignore
urlValue = path.join(rUrl.pathname, urlValue); urlValue = path.join(rUrl.pathname, urlValue);
} }
@ -53,7 +53,7 @@ export default class URLRewriteFilter implements ContentFilter {
url.startsWith("http") || url.startsWith("http") ||
(url.startsWith("//") && isICANN(url)); (url.startsWith("//") && isICANN(url));
if (!isExternal || !isICANN(url)) { if (!isExternal || !isICANN(url)) {
if (!isExternal) { if (!isExternal && !url.startsWith("/")) {
//@ts-ignore //@ts-ignore
url = path.join(rUrl.pathname, url); url = path.join(rUrl.pathname, url);
} }