fix: better handle the requested url by only using pathname and hostname
This commit is contained in:
parent
52c11f350e
commit
98a9ae660d
|
@ -20,6 +20,8 @@ export default class URLRewriteFilter implements ContentFilter {
|
|||
|
||||
const $ = cheerio.load(html);
|
||||
|
||||
const rUrl = new URL(requestor);
|
||||
|
||||
["a", "link", "script", "img"].forEach((tag) => {
|
||||
$.root()
|
||||
.find(tag)
|
||||
|
@ -31,9 +33,9 @@ export default class URLRewriteFilter implements ContentFilter {
|
|||
if (!isExternal || !isICANN(urlValue)) {
|
||||
if (!isExternal) {
|
||||
//@ts-ignore
|
||||
urlValue = path.join(requestor, urlValue);
|
||||
urlValue = path.join(rUrl.pathname, urlValue);
|
||||
}
|
||||
urlValue = `${swUrl.protocol}//${swUrl.hostname}/browse/${urlValue}`;
|
||||
urlValue = `${swUrl.protocol}//${swUrl.hostname}/browse/${rUrl.hostname}${urlValue}`;
|
||||
console.log(urlValue);
|
||||
|
||||
$(element).attr(attrName, urlValue);
|
||||
|
|
Loading…
Reference in New Issue