diff --git a/lib/parse.js b/lib/parse.js index 7d343ca..48d2981 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -103,7 +103,7 @@ module.exports = function (input) { // Comments } else if (code === slash && value.charCodeAt(pos + 1) === star) { - next = value.indexOf("*/", pos); + next = value.indexOf("*/", pos + 2); token = { type: "comment", diff --git a/test/parse.js b/test/parse.js index 22aa393..02a2e59 100644 --- a/test/parse.js +++ b/test/parse.js @@ -1553,6 +1553,19 @@ const tests = [ }, ], }, + { + message: "should not treat the opening slash-star as its own terminator", + fixture: "/*/", + expected: [ + { + type: "comment", + sourceIndex: 0, + sourceEndIndex: 3, + value: "/", + unclosed: true, + }, + ], + }, { message: "should respect escape character", fixture: "Hawaii \\35 -0",