mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-12 22:10:01 -04:00
rewrite http-equiv
This commit is contained in:
parent
dc490064d3
commit
0e37a7f267
1 changed files with 10 additions and 1 deletions
|
@ -55,7 +55,16 @@ function traverseParsedHtml(node, origin?: URL) {
|
|||
}
|
||||
|
||||
if (node.name === "meta" && hasAttrib(node, "http-equiv")) {
|
||||
node.attribs["http-equiv"] = "a";
|
||||
const content = node.attribs.content;
|
||||
|
||||
const regex =
|
||||
/(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,})/;
|
||||
|
||||
if (regex.test(content)) {
|
||||
const url = content.match(regex)[0];
|
||||
|
||||
node.attribs.content = content.replace(url, encodeUrl(url, origin));
|
||||
}
|
||||
}
|
||||
|
||||
if (hasAttrib(node, "srcdoc"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue