@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.mjs
CHANGED
|
@@ -1785,10 +1785,30 @@ function trimZeros(numStr) {
|
|
|
1785
1785
|
return numStr;
|
|
1786
1786
|
}
|
|
1787
1787
|
var strnum = toNumber$1;
|
|
1788
|
+
function getIgnoreAttributesFn$2(ignoreAttributes2) {
|
|
1789
|
+
if (typeof ignoreAttributes2 === "function") {
|
|
1790
|
+
return ignoreAttributes2;
|
|
1791
|
+
}
|
|
1792
|
+
if (Array.isArray(ignoreAttributes2)) {
|
|
1793
|
+
return (attrName) => {
|
|
1794
|
+
for (const pattern of ignoreAttributes2) {
|
|
1795
|
+
if (typeof pattern === "string" && attrName === pattern) {
|
|
1796
|
+
return true;
|
|
1797
|
+
}
|
|
1798
|
+
if (pattern instanceof RegExp && pattern.test(attrName)) {
|
|
1799
|
+
return true;
|
|
1800
|
+
}
|
|
1801
|
+
}
|
|
1802
|
+
};
|
|
1803
|
+
}
|
|
1804
|
+
return () => false;
|
|
1805
|
+
}
|
|
1806
|
+
var ignoreAttributes = getIgnoreAttributesFn$2;
|
|
1788
1807
|
const util = util$3;
|
|
1789
1808
|
const xmlNode = xmlNode$1;
|
|
1790
1809
|
const readDocType = DocTypeReader;
|
|
1791
1810
|
const toNumber = strnum;
|
|
1811
|
+
const getIgnoreAttributesFn$1 = ignoreAttributes;
|
|
1792
1812
|
let OrderedObjParser$1 = class OrderedObjParser {
|
|
1793
1813
|
constructor(options) {
|
|
1794
1814
|
this.options = options;
|
|
@@ -1829,6 +1849,7 @@ let OrderedObjParser$1 = class OrderedObjParser {
|
|
|
1829
1849
|
this.readStopNodeData = readStopNodeData;
|
|
1830
1850
|
this.saveTextToParentTag = saveTextToParentTag;
|
|
1831
1851
|
this.addChild = addChild;
|
|
1852
|
+
this.ignoreAttributesFn = getIgnoreAttributesFn$1(this.options.ignoreAttributes);
|
|
1832
1853
|
}
|
|
1833
1854
|
};
|
|
1834
1855
|
function addExternalEntities(externalEntities) {
|
|
@@ -1881,12 +1902,15 @@ function resolveNameSpace(tagname) {
|
|
|
1881
1902
|
}
|
|
1882
1903
|
const attrsRegx = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
|
|
1883
1904
|
function buildAttributesMap(attrStr, jPath, tagName) {
|
|
1884
|
-
if (
|
|
1905
|
+
if (this.options.ignoreAttributes !== true && typeof attrStr === "string") {
|
|
1885
1906
|
const matches = util.getAllMatches(attrStr, attrsRegx);
|
|
1886
1907
|
const len = matches.length;
|
|
1887
1908
|
const attrs = {};
|
|
1888
1909
|
for (let i = 0; i < len; i++) {
|
|
1889
1910
|
const attrName = this.resolveNameSpace(matches[i][1]);
|
|
1911
|
+
if (this.ignoreAttributesFn(attrName, jPath)) {
|
|
1912
|
+
continue;
|
|
1913
|
+
}
|
|
1890
1914
|
let oldVal = matches[i][4];
|
|
1891
1915
|
let aName = this.options.attributeNamePrefix + attrName;
|
|
1892
1916
|
if (attrName.length) {
|
|
@@ -2521,6 +2545,7 @@ function replaceEntitiesValue(textValue, options) {
|
|
|
2521
2545
|
}
|
|
2522
2546
|
var orderedJs2Xml = toXml;
|
|
2523
2547
|
const buildFromOrderedJs = orderedJs2Xml;
|
|
2548
|
+
const getIgnoreAttributesFn = ignoreAttributes;
|
|
2524
2549
|
const defaultOptions = {
|
|
2525
2550
|
attributeNamePrefix: "@_",
|
|
2526
2551
|
attributesGroupName: false,
|
|
@@ -2557,11 +2582,12 @@ const defaultOptions = {
|
|
|
2557
2582
|
};
|
|
2558
2583
|
function Builder(options) {
|
|
2559
2584
|
this.options = Object.assign({}, defaultOptions, options);
|
|
2560
|
-
if (this.options.ignoreAttributes || this.options.attributesGroupName) {
|
|
2585
|
+
if (this.options.ignoreAttributes === true || this.options.attributesGroupName) {
|
|
2561
2586
|
this.isAttribute = function() {
|
|
2562
2587
|
return false;
|
|
2563
2588
|
};
|
|
2564
2589
|
} else {
|
|
2590
|
+
this.ignoreAttributesFn = getIgnoreAttributesFn(this.options.ignoreAttributes);
|
|
2565
2591
|
this.attrPrefixLen = this.options.attributeNamePrefix.length;
|
|
2566
2592
|
this.isAttribute = isAttribute;
|
|
2567
2593
|
}
|
|
@@ -2587,12 +2613,13 @@ Builder.prototype.build = function(jObj) {
|
|
|
2587
2613
|
[this.options.arrayNodeName]: jObj
|
|
2588
2614
|
};
|
|
2589
2615
|
}
|
|
2590
|
-
return this.j2x(jObj, 0).val;
|
|
2616
|
+
return this.j2x(jObj, 0, []).val;
|
|
2591
2617
|
}
|
|
2592
2618
|
};
|
|
2593
|
-
Builder.prototype.j2x = function(jObj, level) {
|
|
2619
|
+
Builder.prototype.j2x = function(jObj, level, ajPath) {
|
|
2594
2620
|
let attrStr = "";
|
|
2595
2621
|
let val2 = "";
|
|
2622
|
+
const jPath = ajPath.join(".");
|
|
2596
2623
|
for (let key in jObj) {
|
|
2597
2624
|
if (!Object.prototype.hasOwnProperty.call(jObj, key)) continue;
|
|
2598
2625
|
if (typeof jObj[key] === "undefined") {
|
|
@@ -2611,9 +2638,9 @@ Builder.prototype.j2x = function(jObj, level) {
|
|
|
2611
2638
|
val2 += this.buildTextValNode(jObj[key], key, "", level);
|
|
2612
2639
|
} else if (typeof jObj[key] !== "object") {
|
|
2613
2640
|
const attr = this.isAttribute(key);
|
|
2614
|
-
if (attr) {
|
|
2641
|
+
if (attr && !this.ignoreAttributesFn(attr, jPath)) {
|
|
2615
2642
|
attrStr += this.buildAttrPairStr(attr, "" + jObj[key]);
|
|
2616
|
-
} else {
|
|
2643
|
+
} else if (!attr) {
|
|
2617
2644
|
if (key === this.options.textNodeName) {
|
|
2618
2645
|
let newval = this.options.tagValueProcessor(key, "" + jObj[key]);
|
|
2619
2646
|
val2 += this.replaceEntitiesValue(newval);
|
|
@@ -2633,13 +2660,13 @@ Builder.prototype.j2x = function(jObj, level) {
|
|
|
2633
2660
|
else val2 += this.indentate(level) + "<" + key + "/" + this.tagEndChar;
|
|
2634
2661
|
} else if (typeof item === "object") {
|
|
2635
2662
|
if (this.options.oneListGroup) {
|
|
2636
|
-
const result = this.j2x(item, level + 1);
|
|
2663
|
+
const result = this.j2x(item, level + 1, ajPath.concat(key));
|
|
2637
2664
|
listTagVal += result.val;
|
|
2638
2665
|
if (this.options.attributesGroupName && item.hasOwnProperty(this.options.attributesGroupName)) {
|
|
2639
2666
|
listTagAttr += result.attrStr;
|
|
2640
2667
|
}
|
|
2641
2668
|
} else {
|
|
2642
|
-
listTagVal += this.processTextOrObjNode(item, key, level);
|
|
2669
|
+
listTagVal += this.processTextOrObjNode(item, key, level, ajPath);
|
|
2643
2670
|
}
|
|
2644
2671
|
} else {
|
|
2645
2672
|
if (this.options.oneListGroup) {
|
|
@@ -2663,7 +2690,7 @@ Builder.prototype.j2x = function(jObj, level) {
|
|
|
2663
2690
|
attrStr += this.buildAttrPairStr(Ks[j], "" + jObj[key][Ks[j]]);
|
|
2664
2691
|
}
|
|
2665
2692
|
} else {
|
|
2666
|
-
val2 += this.processTextOrObjNode(jObj[key], key, level);
|
|
2693
|
+
val2 += this.processTextOrObjNode(jObj[key], key, level, ajPath);
|
|
2667
2694
|
}
|
|
2668
2695
|
}
|
|
2669
2696
|
}
|
|
@@ -2676,8 +2703,8 @@ Builder.prototype.buildAttrPairStr = function(attrName, val2) {
|
|
|
2676
2703
|
return " " + attrName;
|
|
2677
2704
|
} else return " " + attrName + '="' + val2 + '"';
|
|
2678
2705
|
};
|
|
2679
|
-
function processTextOrObjNode(object, key, level) {
|
|
2680
|
-
const result = this.j2x(object, level + 1);
|
|
2706
|
+
function processTextOrObjNode(object, key, level, ajPath) {
|
|
2707
|
+
const result = this.j2x(object, level + 1, ajPath.concat(key));
|
|
2681
2708
|
if (object[this.options.textNodeName] !== void 0 && Object.keys(object).length === 1) {
|
|
2682
2709
|
return this.buildTextValNode(object[this.options.textNodeName], key, result.attrStr, level);
|
|
2683
2710
|
} else {
|