@nextcloud/files 3.0.0 → 3.1.0

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.mjs CHANGED
@@ -639,8 +639,10 @@ class D {
639
639
  */
640
640
  get dirname() {
641
641
  if (this.root) {
642
- const r = this.source.indexOf(this.root);
643
- return I(this.source.slice(r + this.root.length) || "/");
642
+ let r = this.source;
643
+ this.isDavRessource && (r = r.split(this._knownDavService).pop());
644
+ const s = r.indexOf(this.root), n = this.root.replace(/\/$/, "");
645
+ return I(r.slice(s + n.length) || "/");
644
646
  }
645
647
  const t = new URL(this.source);
646
648
  return I(t.pathname);
@@ -704,8 +706,10 @@ class D {
704
706
  */
705
707
  get path() {
706
708
  if (this.root) {
707
- const t = this.source.indexOf(this.root);
708
- return this.source.slice(t + this.root.length) || "/";
709
+ let t = this.source;
710
+ this.isDavRessource && (t = t.split(this._knownDavService).pop());
711
+ const r = t.indexOf(this.root), s = this.root.replace(/\/$/, "");
712
+ return t.slice(r + s.length) || "/";
709
713
  }
710
714
  return (this.dirname + "/" + this.basename).replace(/\/\//g, "/");
711
715
  }
@@ -841,20 +845,21 @@ class _e extends D {
841
845
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
842
846
  *
843
847
  */
844
- const ee = `/files/${A()?.uid}`, te = pe("dav"), ur = function(e = te) {
845
- const t = ge(e);
846
- function r(n) {
847
- t.setHeaders({
848
+ const ee = `/files/${A()?.uid}`, te = pe("dav"), ur = function(e = te, t = {}) {
849
+ const r = ge(e, { headers: t });
850
+ function s(i) {
851
+ r.setHeaders({
852
+ ...t,
848
853
  // Add this so the server knows it is an request from the browser
849
854
  "X-Requested-With": "XMLHttpRequest",
850
855
  // Inject user auth
851
- requesttoken: n ?? ""
856
+ requesttoken: i ?? ""
852
857
  });
853
858
  }
854
- return ue(r), r(de()), we().patch("fetch", (n, i) => {
855
- const d = i.headers;
856
- return d?.method && (i.method = d.method, delete d.method), fetch(n, i);
857
- }), t;
859
+ return ue(s), s(de()), we().patch("fetch", (i, d) => {
860
+ const u = d.headers;
861
+ return u?.method && (d.method = u.method, delete u.method), fetch(i, d);
862
+ }), r;
858
863
  }, dr = async (e, t = "/", r = ee) => (await e.getDirectoryContents(`${r}${t}`, {
859
864
  details: !0,
860
865
  data: Ee(),
@@ -864,7 +869,7 @@ const ee = `/files/${A()?.uid}`, te = pe("dav"), ur = function(e = te) {
864
869
  },
865
870
  includeSelf: !0
866
871
  })).data.filter((n) => n.filename !== t).map((n) => ve(n, r)), ve = function(e, t = ee, r = te) {
867
- const s = e.props, n = be(s?.permissions), i = A()?.uid, d = {
872
+ const s = e.props, n = be(s?.permissions), i = s?.["owner-id"] || A()?.uid, d = {
868
873
  id: s?.fileid || 0,
869
874
  source: `${r}${e.filename}`,
870
875
  mtime: new Date(Date.parse(e.lastmod)),
@@ -1246,7 +1251,7 @@ function w(e, t) {
1246
1251
  function v(e) {
1247
1252
  return e.startIndex + e[1].length;
1248
1253
  }
1249
- var B = {};
1254
+ var k = {};
1250
1255
  const re = {
1251
1256
  preserveOrder: !1,
1252
1257
  attributeNamePrefix: "@_",
@@ -1293,8 +1298,8 @@ const re = {
1293
1298
  }, Se = function(e) {
1294
1299
  return Object.assign({}, re, e);
1295
1300
  };
1296
- B.buildOptions = Se;
1297
- B.defaultOptions = re;
1301
+ k.buildOptions = Se;
1302
+ k.defaultOptions = re;
1298
1303
  class Me {
1299
1304
  constructor(t) {
1300
1305
  this.tagname = t, this.child = [], this[":@"] = {};
@@ -1306,8 +1311,8 @@ class Me {
1306
1311
  t.tagname === "__proto__" && (t.tagname = "#__proto__"), t[":@"] && Object.keys(t[":@"]).length > 0 ? this.child.push({ [t.tagname]: t.child, ":@": t[":@"] }) : this.child.push({ [t.tagname]: t.child });
1307
1312
  }
1308
1313
  }
1309
- var Be = Me;
1310
- const ke = O;
1314
+ var ke = Me;
1315
+ const Be = O;
1311
1316
  function qe(e, t) {
1312
1317
  const r = {};
1313
1318
  if (e[t + 3] === "O" && e[t + 4] === "C" && e[t + 5] === "T" && e[t + 6] === "Y" && e[t + 7] === "P" && e[t + 8] === "E") {
@@ -1370,7 +1375,7 @@ function Ke(e, t) {
1370
1375
  return e[t + 1] === "!" && e[t + 2] === "N" && e[t + 3] === "O" && e[t + 4] === "T" && e[t + 5] === "A" && e[t + 6] === "T" && e[t + 7] === "I" && e[t + 8] === "O" && e[t + 9] === "N";
1371
1376
  }
1372
1377
  function We(e) {
1373
- if (ke.isName(e))
1378
+ if (Be.isName(e))
1374
1379
  return e;
1375
1380
  throw new Error(`Invalid entity name ${e}`);
1376
1381
  }
@@ -1415,8 +1420,8 @@ function De(e) {
1415
1420
  return e && e.indexOf(".") !== -1 && (e = e.replace(/0+$/, ""), e === "." ? e = "0" : e[0] === "." ? e = "0" + e : e[e.length - 1] === "." && (e = e.substr(0, e.length - 1))), e;
1416
1421
  }
1417
1422
  var et = Qe;
1418
- const k = O, T = Be, tt = Ze, rt = et;
1419
- "<((!\\[CDATA\\[([\\s\\S]*?)(]]>))|((NAME:)?(NAME))([^>]*)>|((\\/)(NAME)\\s*>))([^<]*)".replace(/NAME/g, k.nameRegexp);
1423
+ const B = O, T = ke, tt = Ze, rt = et;
1424
+ "<((!\\[CDATA\\[([\\s\\S]*?)(]]>))|((NAME:)?(NAME))([^>]*)>|((\\/)(NAME)\\s*>))([^<]*)".replace(/NAME/g, B.nameRegexp);
1420
1425
  let nt = class {
1421
1426
  constructor(t) {
1422
1427
  this.options = t, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = {
@@ -1470,7 +1475,7 @@ function ot(e) {
1470
1475
  const ut = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
1471
1476
  function dt(e, t, r) {
1472
1477
  if (!this.options.ignoreAttributes && typeof e == "string") {
1473
- const s = k.getAllMatches(e, ut), n = s.length, i = {};
1478
+ const s = B.getAllMatches(e, ut), n = s.length, i = {};
1474
1479
  for (let d = 0; d < n; d++) {
1475
1480
  const u = this.resolveNameSpace(s[d][1]);
1476
1481
  let o = s[d][4], a = this.options.attributeNamePrefix + u;
@@ -1702,7 +1707,7 @@ function $(e, t, r) {
1702
1707
  const s = e.trim();
1703
1708
  return s === "true" ? !0 : s === "false" ? !1 : rt(e, r);
1704
1709
  } else
1705
- return k.isExist(e) ? e : "";
1710
+ return B.isExist(e) ? e : "";
1706
1711
  }
1707
1712
  var wt = nt, ne = {};
1708
1713
  function mt(e, t) {
@@ -1750,7 +1755,7 @@ function bt(e, t) {
1750
1755
  return !!(s === 0 || s === 1 && (e[r] || typeof e[r] == "boolean" || e[r] === 0));
1751
1756
  }
1752
1757
  ne.prettify = mt;
1753
- const { buildOptions: yt } = B, _t = wt, { prettify: vt } = ne, Tt = S;
1758
+ const { buildOptions: yt } = k, _t = wt, { prettify: vt } = ne, Tt = S;
1754
1759
  let It = class {
1755
1760
  constructor(t) {
1756
1761
  this.externalEntities = {}, this.options = yt(t);
@@ -1994,10 +1999,10 @@ function St(e) {
1994
1999
  return e.startsWith(this.options.attributeNamePrefix) && e !== this.options.textNodeName ? e.substr(this.attrPrefixLen) : !1;
1995
2000
  }
1996
2001
  var Mt = b;
1997
- const Bt = S, kt = At, qt = Mt;
2002
+ const kt = S, Bt = At, qt = Mt;
1998
2003
  var W = {
1999
- XMLParser: kt,
2000
- XMLValidator: Bt,
2004
+ XMLParser: Bt,
2005
+ XMLValidator: kt,
2001
2006
  XMLBuilder: qt
2002
2007
  };
2003
2008
  function Xt(e) {