Skip to content

Commit

Permalink
fix(sig): update workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
skick1234 committed Dec 17, 2024
1 parent 41e5188 commit 15d3b14
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/sig.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ const extractDecipherWithName = (exports.d2 = body => {
}
});

const getExtractFunctions = (extractFunctions, body) => {
const getExtractFunctions = (extractFunctions, body, postProcess = null) => {
for (const extractFunction of extractFunctions) {
try {
const func = extractFunction(body);
if (!func) continue;
return new vm.Script(func);
return new vm.Script(postProcess ? postProcess(func) : func);
} catch (err) {
continue;
}
Expand Down Expand Up @@ -193,7 +193,9 @@ const extractNTransformWithName = (exports.n2 = body => {
let nTransformWarning = false;
const extractNTransform = body => {
// Faster: extractNTransformFunc
const nTransformFunc = getExtractFunctions([extractNTransformFunc, extractNTransformWithName], body);
const nTransformFunc = getExtractFunctions([extractNTransformFunc, extractNTransformWithName], body, code =>
code.replace(/if\(typeof \S*==="undefined"\)return \S*;/, ""),
);
if (!nTransformFunc && !nTransformWarning) {
// This is optional, so we can continue if it's not found, but it will bottleneck the download.
console.warn(
Expand Down

0 comments on commit 15d3b14

Please sign in to comment.