Skip to content

Commit 3af085a

Browse files
committed
JS: Drive-by allow trailing commas in dynamic imports
1 parent 8d9060f commit 3af085a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

javascript/extractor/src/com/semmle/jcorn/ESNextParser.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,10 @@ private DynamicImport parseDynamicImport(Position startLoc) {
439439
Expression source = parseMaybeAssign(false, null, null);
440440
Expression attributes = null;
441441
if (this.eat(TokenType.comma)) {
442-
attributes = this.parseMaybeAssign(false, null, null);
442+
if (this.type != TokenType.parenR) { // Skip if the comma was a trailing comma
443+
attributes = this.parseMaybeAssign(false, null, null);
444+
this.eat(TokenType.comma); // Allow trailing comma
445+
}
443446
}
444447
this.expect(TokenType.parenR);
445448
DynamicImport di = this.finishNode(new DynamicImport(new SourceLocation(startLoc), source, attributes));

0 commit comments

Comments
 (0)