diff --git a/src/scriptlets/trusted-suppress-native-method.ts b/src/scriptlets/trusted-suppress-native-method.ts index 3cfce6457..e559ff76b 100644 --- a/src/scriptlets/trusted-suppress-native-method.ts +++ b/src/scriptlets/trusted-suppress-native-method.ts @@ -101,7 +101,7 @@ import { * @added unknown. */ /* eslint-enable max-len */ -export function TrustedSuppressNativeMethod( +export function trustedSuppressNativeMethod( source: Source, methodPath: string, signatureStr: string, @@ -155,25 +155,25 @@ export function TrustedSuppressNativeMethod( return; } + /** + * Matches the incoming arguments with the signature matcher. + * + * @param nativeArguments original arguments of the native method call + * @param matchArguments matcher to match against the native argument + * @returns true, if each of the signature matchers match their corresponding argument. + */ function matchMethodCall( nativeArguments: unknown[], matchArguments: unknown[], ): boolean { - for (let i = 0; i < matchArguments.length; i += 1) { - const matcher = matchArguments[i]; + return matchArguments.every((matcher, i) => { if (matcher === IGNORE_ARG_SYMBOL) { - continue; + return true; } const argument = nativeArguments[i]; - if (!isValueMatched(argument, matcher)) { - return false; - } - - continue; - } - - return true; + return isValueMatched(argument, matcher); + }); } // This flag allows to prevent infinite loops when trapping props that are used by scriptlet's own code. @@ -204,11 +204,11 @@ export function TrustedSuppressNativeMethod( base[prop] = new Proxy(nativeMethod, { apply }); } -TrustedSuppressNativeMethod.names = [ +trustedSuppressNativeMethod.names = [ 'trusted-suppress-native-method', ]; -TrustedSuppressNativeMethod.injections = [ +trustedSuppressNativeMethod.injections = [ hit, logMessage, getPropertyInChain,