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.
3535This is equivalent to ` new RegExpParser(options).parseLiteral(source) ` .
3636
3737- ** Parameters:**
38- - ` source ` (` string ` ) The source code to parse.
38+ - ` source ` (` string | RegExp ` ) The source code to parse.
3939 - ` options? ` ([ ` RegExpParser.Options ` ] ) The options to parse.
4040- ** Return:**
4141 - The AST of the regular expression.
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ export function parseRegExpLiteral(
1515 source : string | RegExp ,
1616 options ?: RegExpParser . Options ,
1717) : AST . RegExpLiteral {
18- return new RegExpParser ( options ) . parseLiteral ( source instanceof RegExp ? String ( source ) : source )
18+ return new RegExpParser ( options ) . parseLiteral ( String ( source ) )
1919}
2020
2121/**
Original file line number Diff line number Diff line change @@ -50,6 +50,13 @@ describe("parseRegExpLiteral function:", () => {
5050 }
5151 } )
5252 }
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+ } )
5360} )
5461
5562for ( const filename of Object . keys ( Fixtures ) ) {
You can’t perform that action at this time.
0 commit comments