minify-xml
Advanced tools
Comparing version 2.1.4 to 2.1.5
17
index.js
@@ -16,7 +16,14 @@ "use strict"; // we are overriding arguments, so this is important! | ||
// character, simply checking for (?<=<[^>]*) would not do the trick if e.g. > is used inside of a tag attribute. | ||
const emptyRegexp = new RegExp(), inTagPattern = /(?<=<[^\s>]+(?:\s+[^=\s>]+\s*=\s*(?:"[^"]*"|'[^']*'))*\1)/; | ||
const emptyRegexp = new RegExp(), inTagPattern = /(?<=<[^\s>]*(?:\s+[^=\s>]+\s*=\s*(?:"[^"]*"|'[^']*'))*\1)/; | ||
function findAllMatchesInTags(xml, regexp, lookbehind, group) { | ||
if (!(lookbehind instanceof RegExp)) { | ||
group = lookbehind; lookbehind = emptyRegexp; | ||
} | ||
return findAllMatches(xml, new RegExp(inTagPattern.source.replace("\\1", | ||
lookbehind.source) + regexp.source, "g"), group); | ||
} | ||
function replaceInTags(xml, regexp, lookbehind, replacement) { | ||
if (!replacement) { | ||
replacement = lookbehind; | ||
lookbehind = emptyRegexp; | ||
if (!(lookbehind instanceof RegExp)) { | ||
replacement = lookbehind; lookbehind = emptyRegexp; | ||
} | ||
@@ -96,3 +103,3 @@ | ||
...findAllMatches(xml, /<([^<\s\/]+):/g, 1), // look for all tags with namespaces (limitation: might also include tags inside of CData, we ignore that for now) | ||
...findAllMatches(xml, /<[^<\s>]+(?:(?:\s+(?:([^=\s>]+):)?[^=\s>]+)\s*=\s*(?:"[^"]*"|'[^']*'))*/g, 1) // look for all attributes with namespaces | ||
...findAllMatchesInTags(xml, /(?:\s+(?:([^=\s>]+):[^=\s>]+))/, 1) // look for all attributes with namespaces | ||
], unused = all.filter(ns => !used.includes(ns)); | ||
@@ -99,0 +106,0 @@ |
{ | ||
"name": "minify-xml", | ||
"version": "2.1.4", | ||
"version": "2.1.5", | ||
"description": "Fast XML minifier / compressor / uglifier with a command-line", | ||
@@ -19,12 +19,11 @@ "keywords": [ | ||
"scripts": { | ||
"test": "node test.js" | ||
"test": "ava" | ||
}, | ||
"files": [ | ||
"cli.js", | ||
"test.js" | ||
"cli.js" | ||
], | ||
"engines": { | ||
"node": ">=10" | ||
"node": ">=10" | ||
}, | ||
"author": { | ||
"author": { | ||
"name": "Kristian Kraljic", | ||
@@ -47,3 +46,7 @@ "email": "kris@kra.lc", | ||
"meow": "^7.0.1" | ||
}, | ||
"devDependencies": { | ||
"ava": "^3.13.0", | ||
"glob": "^7.1.6" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22913
2
5
125