@nextcloud/files 3.9.0 → 3.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +38 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +38 -11
- package/dist/index.mjs.map +1 -1
- package/dist/vendor.LICENSE.txt +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -1787,10 +1787,30 @@ function trimZeros(numStr) {
|
|
|
1787
1787
|
return numStr;
|
|
1788
1788
|
}
|
|
1789
1789
|
var strnum = toNumber$1;
|
|
1790
|
+
function getIgnoreAttributesFn$2(ignoreAttributes2) {
|
|
1791
|
+
if (typeof ignoreAttributes2 === "function") {
|
|
1792
|
+
return ignoreAttributes2;
|
|
1793
|
+
}
|
|
1794
|
+
if (Array.isArray(ignoreAttributes2)) {
|
|
1795
|
+
return (attrName) => {
|
|
1796
|
+
for (const pattern of ignoreAttributes2) {
|
|
1797
|
+
if (typeof pattern === "string" && attrName === pattern) {
|
|
1798
|
+
return true;
|
|
1799
|
+
}
|
|
1800
|
+
if (pattern instanceof RegExp && pattern.test(attrName)) {
|
|
1801
|
+
return true;
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
};
|
|
1805
|
+
}
|
|
1806
|
+
return () => false;
|
|
1807
|
+
}
|
|
1808
|
+
var ignoreAttributes = getIgnoreAttributesFn$2;
|
|
1790
1809
|
const util = util$3;
|
|
1791
1810
|
const xmlNode = xmlNode$1;
|
|
1792
1811
|
const readDocType = DocTypeReader;
|
|
1793
1812
|
const toNumber = strnum;
|
|
1813
|
+
const getIgnoreAttributesFn$1 = ignoreAttributes;
|
|
1794
1814
|
let OrderedObjParser$1 = class OrderedObjParser {
|
|
1795
1815
|
constructor(options) {
|
|
1796
1816
|
this.options = options;
|
|
@@ -1831,6 +1851,7 @@ let OrderedObjParser$1 = class OrderedObjParser {
|
|
|
1831
1851
|
this.readStopNodeData = readStopNodeData;
|
|
1832
1852
|
this.saveTextToParentTag = saveTextToParentTag;
|
|
1833
1853
|
this.addChild = addChild;
|
|
1854
|
+
this.ignoreAttributesFn = getIgnoreAttributesFn$1(this.options.ignoreAttributes);
|
|
1834
1855
|
}
|
|
1835
1856
|
};
|
|
1836
1857
|
function addExternalEntities(externalEntities) {
|
|
@@ -1883,12 +1904,15 @@ function resolveNameSpace(tagname) {
|
|
|
1883
1904
|
}
|
|
1884
1905
|
const attrsRegx = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
|
|
1885
1906
|
function buildAttributesMap(attrStr, jPath, tagName) {
|
|
1886
|
-
if (
|
|
1907
|
+
if (this.options.ignoreAttributes !== true && typeof attrStr === "string") {
|
|
1887
1908
|
const matches = util.getAllMatches(attrStr, attrsRegx);
|
|
1888
1909
|
const len = matches.length;
|
|
1889
1910
|
const attrs = {};
|
|
1890
1911
|
for (let i = 0; i < len; i++) {
|
|
1891
1912
|
const attrName = this.resolveNameSpace(matches[i][1]);
|
|
1913
|
+
if (this.ignoreAttributesFn(attrName, jPath)) {
|
|
1914
|
+
continue;
|
|
1915
|
+
}
|
|
1892
1916
|
let oldVal = matches[i][4];
|
|
1893
1917
|
let aName = this.options.attributeNamePrefix + attrName;
|
|
1894
1918
|
if (attrName.length) {
|
|
@@ -2523,6 +2547,7 @@ function replaceEntitiesValue(textValue, options) {
|
|
|
2523
2547
|
}
|
|
2524
2548
|
var orderedJs2Xml = toXml;
|
|
2525
2549
|
const buildFromOrderedJs = orderedJs2Xml;
|
|
2550
|
+
const getIgnoreAttributesFn = ignoreAttributes;
|
|
2526
2551
|
const defaultOptions = {
|
|
2527
2552
|
attributeNamePrefix: "@_",
|
|
2528
2553
|
attributesGroupName: false,
|
|
@@ -2559,11 +2584,12 @@ const defaultOptions = {
|
|
|
2559
2584
|
};
|
|
2560
2585
|
function Builder(options) {
|
|
2561
2586
|
this.options = Object.assign({}, defaultOptions, options);
|
|
2562
|
-
if (this.options.ignoreAttributes || this.options.attributesGroupName) {
|
|
2587
|
+
if (this.options.ignoreAttributes === true || this.options.attributesGroupName) {
|
|
2563
2588
|
this.isAttribute = function() {
|
|
2564
2589
|
return false;
|
|
2565
2590
|
};
|
|
2566
2591
|
} else {
|
|
2592
|
+
this.ignoreAttributesFn = getIgnoreAttributesFn(this.options.ignoreAttributes);
|
|
2567
2593
|
this.attrPrefixLen = this.options.attributeNamePrefix.length;
|
|
2568
2594
|
this.isAttribute = isAttribute;
|
|
2569
2595
|
}
|
|
@@ -2589,12 +2615,13 @@ Builder.prototype.build = function(jObj) {
|
|
|
2589
2615
|
[this.options.arrayNodeName]: jObj
|
|
2590
2616
|
};
|
|
2591
2617
|
}
|
|
2592
|
-
return this.j2x(jObj, 0).val;
|
|
2618
|
+
return this.j2x(jObj, 0, []).val;
|
|
2593
2619
|
}
|
|
2594
2620
|
};
|
|
2595
|
-
Builder.prototype.j2x = function(jObj, level) {
|
|
2621
|
+
Builder.prototype.j2x = function(jObj, level, ajPath) {
|
|
2596
2622
|
let attrStr = "";
|
|
2597
2623
|
let val2 = "";
|
|
2624
|
+
const jPath = ajPath.join(".");
|
|
2598
2625
|
for (let key in jObj) {
|
|
2599
2626
|
if (!Object.prototype.hasOwnProperty.call(jObj, key)) continue;
|
|
2600
2627
|
if (typeof jObj[key] === "undefined") {
|
|
@@ -2613,9 +2640,9 @@ Builder.prototype.j2x = function(jObj, level) {
|
|
|
2613
2640
|
val2 += this.buildTextValNode(jObj[key], key, "", level);
|
|
2614
2641
|
} else if (typeof jObj[key] !== "object") {
|
|
2615
2642
|
const attr = this.isAttribute(key);
|
|
2616
|
-
if (attr) {
|
|
2643
|
+
if (attr && !this.ignoreAttributesFn(attr, jPath)) {
|
|
2617
2644
|
attrStr += this.buildAttrPairStr(attr, "" + jObj[key]);
|
|
2618
|
-
} else {
|
|
2645
|
+
} else if (!attr) {
|
|
2619
2646
|
if (key === this.options.textNodeName) {
|
|
2620
2647
|
let newval = this.options.tagValueProcessor(key, "" + jObj[key]);
|
|
2621
2648
|
val2 += this.replaceEntitiesValue(newval);
|
|
@@ -2635,13 +2662,13 @@ Builder.prototype.j2x = function(jObj, level) {
|
|
|
2635
2662
|
else val2 += this.indentate(level) + "<" + key + "/" + this.tagEndChar;
|
|
2636
2663
|
} else if (typeof item === "object") {
|
|
2637
2664
|
if (this.options.oneListGroup) {
|
|
2638
|
-
const result = this.j2x(item, level + 1);
|
|
2665
|
+
const result = this.j2x(item, level + 1, ajPath.concat(key));
|
|
2639
2666
|
listTagVal += result.val;
|
|
2640
2667
|
if (this.options.attributesGroupName && item.hasOwnProperty(this.options.attributesGroupName)) {
|
|
2641
2668
|
listTagAttr += result.attrStr;
|
|
2642
2669
|
}
|
|
2643
2670
|
} else {
|
|
2644
|
-
listTagVal += this.processTextOrObjNode(item, key, level);
|
|
2671
|
+
listTagVal += this.processTextOrObjNode(item, key, level, ajPath);
|
|
2645
2672
|
}
|
|
2646
2673
|
} else {
|
|
2647
2674
|
if (this.options.oneListGroup) {
|
|
@@ -2665,7 +2692,7 @@ Builder.prototype.j2x = function(jObj, level) {
|
|
|
2665
2692
|
attrStr += this.buildAttrPairStr(Ks[j], "" + jObj[key][Ks[j]]);
|
|
2666
2693
|
}
|
|
2667
2694
|
} else {
|
|
2668
|
-
val2 += this.processTextOrObjNode(jObj[key], key, level);
|
|
2695
|
+
val2 += this.processTextOrObjNode(jObj[key], key, level, ajPath);
|
|
2669
2696
|
}
|
|
2670
2697
|
}
|
|
2671
2698
|
}
|
|
@@ -2678,8 +2705,8 @@ Builder.prototype.buildAttrPairStr = function(attrName, val2) {
|
|
|
2678
2705
|
return " " + attrName;
|
|
2679
2706
|
} else return " " + attrName + '="' + val2 + '"';
|
|
2680
2707
|
};
|
|
2681
|
-
function processTextOrObjNode(object, key, level) {
|
|
2682
|
-
const result = this.j2x(object, level + 1);
|
|
2708
|
+
function processTextOrObjNode(object, key, level, ajPath) {
|
|
2709
|
+
const result = this.j2x(object, level + 1, ajPath.concat(key));
|
|
2683
2710
|
if (object[this.options.textNodeName] !== void 0 && Object.keys(object).length === 1) {
|
|
2684
2711
|
return this.buildTextValNode(object[this.options.textNodeName], key, result.attrStr, level);
|
|
2685
2712
|
} else {
|