File tree Expand file tree Collapse file tree 3 files changed +9
-2
lines changed Expand file tree Collapse file tree 3 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ Parse a given regular expression literal then make AST object.
35
35
This is equivalent to ` new RegExpParser(options).parseLiteral(source) ` .
36
36
37
37
- ** Parameters:**
38
- - ` source ` (` string ` ) The source code to parse.
38
+ - ` source ` (` string | RegExp ` ) The source code to parse.
39
39
- ` options? ` ([ ` RegExpParser.Options ` ] ) The options to parse.
40
40
- ** Return:**
41
41
- The AST of the regular expression.
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ export function parseRegExpLiteral(
15
15
source : string | RegExp ,
16
16
options ?: RegExpParser . Options ,
17
17
) : AST . RegExpLiteral {
18
- return new RegExpParser ( options ) . parseLiteral ( source instanceof RegExp ? String ( source ) : source )
18
+ return new RegExpParser ( options ) . parseLiteral ( String ( source ) )
19
19
}
20
20
21
21
/**
Original file line number Diff line number Diff line change @@ -50,6 +50,13 @@ describe("parseRegExpLiteral function:", () => {
50
50
}
51
51
} )
52
52
}
53
+
54
+ it ( "should parse RegExp object" , ( ) => {
55
+ const actual = cloneWithoutCircular ( parseRegExpLiteral ( / [ A - Z ] + / ) )
56
+ const expected = cloneWithoutCircular ( parseRegExpLiteral ( "/[A-Z]+/" ) )
57
+
58
+ assert . deepStrictEqual ( actual , expected )
59
+ } )
53
60
} )
54
61
55
62
for ( const filename of Object . keys ( Fixtures ) ) {
You can’t perform that action at this time.
0 commit comments