fix: correct path changes on srcset
This commit is contained in:
parent
47f61909f5
commit
a50a78ea47
|
@ -49,9 +49,18 @@ export default class URLRewriteFilter implements ContentFilter {
|
||||||
let srcsetValues = srcsetValue?.split(",");
|
let srcsetValues = srcsetValue?.split(",");
|
||||||
let rewrittenSrcsetValues = srcsetValues?.map((srcsetEntry) => {
|
let rewrittenSrcsetValues = srcsetValues?.map((srcsetEntry) => {
|
||||||
let [url, descriptor] = srcsetEntry.trim().split(" ");
|
let [url, descriptor] = srcsetEntry.trim().split(" ");
|
||||||
if (!url.startsWith("http") && !url.startsWith("//")) {
|
const isExternal =
|
||||||
url = path.join(rUrl.pathname, url);
|
url.startsWith("http") ||
|
||||||
url = `${rUrl.protocol}//${rUrl.hostname}/browse/${rUrl.hostname}${url}`;
|
(url.startsWith("//") && isICANN(url));
|
||||||
|
if (!isExternal || !isICANN(url)) {
|
||||||
|
if (!isExternal) {
|
||||||
|
//@ts-ignore
|
||||||
|
urlValue = path.join(rUrl.pathname, urlValue);
|
||||||
|
}
|
||||||
|
urlValue = `${swUrl.protocol}//${swUrl.hostname}/browse/${rUrl.hostname}${urlValue}`;
|
||||||
|
console.log(urlValue);
|
||||||
|
|
||||||
|
$(element).attr(attrName, urlValue);
|
||||||
}
|
}
|
||||||
return `${url} ${descriptor}`;
|
return `${url} ${descriptor}`;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue