Comparing version 0.6.2 to 0.6.3
@@ -128,7 +128,10 @@ 'use strict'; | ||
if (!isHtml && (symbol === '\'' || symbol === '"' || symbol === '`')) { | ||
var closeIdx = code.indexOf(symbol, idx + 1); | ||
if (!isHtml && (symbol === '\'' || symbol === '"' || symbol === '`') && (!idx || code[idx - 1] !== '\\')) { | ||
if (checkRegEx && utils.indexInRegEx(idx, regEx)) { | ||
continue; | ||
} | ||
var closeIdx = idx; | ||
do { | ||
closeIdx = code.indexOf(symbol, closeIdx + 1); | ||
} while (closeIdx > 0 && code[closeIdx - 1] === '\\' && (closeIdx < 2 || code[closeIdx - 2] !== '\\')); | ||
if (closeIdx < 0) { | ||
@@ -135,0 +138,0 @@ break; |
{ | ||
"name": "decomment", | ||
"version": "0.6.2", | ||
"version": "0.6.3", | ||
"description": "Removes comments from JSON, JavaScript, CSS, HTML, etc.", | ||
@@ -50,1 +50,2 @@ "main": "lib/index.js", | ||
} | ||
@@ -11,6 +11,17 @@ 'use strict'; | ||
describe("special slash case", function () { | ||
describe("special slash cases", function () { | ||
it("must be ignored", function () { | ||
expect(decomment("'\f'")).toBe("'\f'"); | ||
expect(decomment("'\\''")).toBe("'\\''"); | ||
expect(decomment('"\\""')).toBe('"\\""'); | ||
expect(decomment('`\\``')).toBe('`\\``'); | ||
expect(decomment("'\\'\\''")).toBe("'\\'\\''"); | ||
expect(decomment('"\\"\\""')).toBe('"\\"\\""'); | ||
expect(decomment('`\\`\\``')).toBe('`\\`\\``'); | ||
expect(decomment("'\\\\'")).toBe("'\\\\'"); | ||
expect(decomment('"\\\\"')).toBe('"\\\\"'); | ||
expect(decomment('`\\\\`')).toBe('`\\\\`'); | ||
}); | ||
@@ -17,0 +28,0 @@ }); |
31552
681