Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

decomment

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

decomment - npm Package Compare versions

Comparing version 0.8.2 to 0.8.3

test/ignoreSpec.js

43

lib/parser.js

@@ -25,3 +25,3 @@ 'use strict';

isHtml, // set when the input is recognized as HTML;
regEx; // regular expression details;
regEx = []; // regular expression details;

@@ -41,2 +41,37 @@ if (!len) {

if (options && options.ignore) {
var ignore = options.ignore;
if (ignore instanceof RegExp) {
ignore = [ignore];
} else {
if (ignore instanceof Array) {
ignore = ignore.filter(function (f) {
return f instanceof RegExp;
});
if (!ignore.length) {
ignore = null;
}
} else {
ignore = null;
}
}
if (ignore) {
for (var i = 0; i < ignore.length; i++) {
var match, reg = ignore[i];
do {
match = reg.exec(code);
if (match) {
regEx.push({
start: match.index,
end: match.index + match[0].length - 1
});
}
} while (match && reg.global);
}
regEx = regEx.sort(function (a, b) {
return a.start > b.start;
});
}
}
do {

@@ -124,2 +159,6 @@ if (!isHtml && code[idx] === '/' && idx < len - 1 && (!idx || code[idx - 1] !== '\\')) {

if (isHtml && code[idx] === '<' && idx < len - 3 && code.substr(idx + 1, 3) === '!--') {
if (inRegEx()) {
s += '<';
continue;
}
var end = code.indexOf('-->', idx + 4);

@@ -220,3 +259,3 @@ var keep = optSafe && code.substr(idx + 4, 3) === '[if';

function inRegEx() {
if (regEx && regEx.length) {
if (regEx.length) {
return utils.indexInRegEx(idx, regEx);

@@ -223,0 +262,0 @@ }

2

package.json
{
"name": "decomment",
"version": "0.8.2",
"version": "0.8.3",
"description": "Removes comments from JSON, JavaScript, CSS, HTML, etc.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -86,2 +86,17 @@ decomment

##### options.ignore ⇒ RegExp | [RegExp,...]
Takes either a single or an array of regular expressions to match against.
All matching blocks are ignored, as well as any comment-like content inside them.
For example, CSS may contain Base64-encoded strings with comment-like symbols:
```css
src: url(data:font/woff;base64,d09GRg//ABAAAAAAZ)
```
And you can isolate all `url(*)` blocks by using:
```js
{ignore: /url\([\w\s:\/=\-\+;,]*\)/g}
```
##### options.space ⇒ Boolean

@@ -88,0 +103,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc