File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed
Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import type { MemberExpression } from 'estree';
66
77const META_START = '// ==UserScript==' ;
88const META_END = '// ==/UserScript==' ;
9- const GRANTS_REGEXP = / ^ u n s a f e W i n d o w | G M [ . _ ] [ a - z A - Z 0 - 9 _ ] + / ;
9+ const GRANTS_REGEXP = / ^ ( u n s a f e W i n d o w $ | G M [ . _ ] \w + ) / ;
1010
1111export function collectGrants ( ast : AstNode ) {
1212 let scope = attachScopes ( ast , 'scope' ) ;
Original file line number Diff line number Diff line change @@ -53,6 +53,13 @@ describe('collectGrants', () => {
5353 expect ( result ) . toContain ( 'unsafeWindow' ) ;
5454 } ) ;
5555
56+ it ( 'should return nothing unsafeWindow when presented with unsafeWindowButNotReally' , ( ) => {
57+ const astNode = parseCodeAsEstreeAst ( `unsafeWindowButNotReally` ) ;
58+ const result = collectGrants ( astNode ) ;
59+
60+ expect ( result . size ) . toBe ( 0 ) ;
61+ } ) ;
62+
5663 it ( 'should return unsafeWindow even when a subfield is accessed' , ( ) => {
5764 const astNode = parseCodeAsEstreeAst ( `unsafeWindow.anotherThing` ) ;
5865 const result = collectGrants ( astNode ) ;
You can’t perform that action at this time.
0 commit comments