chore: lint:fix

This commit is contained in:
wearrrrr 2024-10-10 19:31:35 -05:00
parent 4d7fa7abb6
commit e8a8a66397
5 changed files with 22 additions and 13 deletions

View file

@ -219,7 +219,7 @@ function traverseParsedHtml(
) {
let js = node.children[0].data;
// node.attribs[`data-scramjet-script-source-src`] = btoa(js);
node.attribs[`data-scramjet-script-source-src`] = bytesToBase64(
node.attribs["data-scramjet-script-source-src"] = bytesToBase64(
new TextEncoder().encode(js)
);
const htmlcomment = /<!--[\s\S]*?-->/g;
@ -272,12 +272,14 @@ export function rewriteSrcset(srcset: string, meta: URLMeta) {
function base64ToBytes(base64) {
const binString = atob(base64);
return Uint8Array.from(binString, (m) => m.codePointAt(0));
return Uint8Array.from(binString, (m) => m.codePointAt(0));
}
function bytesToBase64(bytes: Uint8Array) {
const binString = Array.from(bytes, (byte) =>
String.fromCodePoint(byte)
).join("");
return btoa(binString);
return btoa(binString);
}