diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index ddb22441..308f8a34 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -7470,11 +7470,11 @@ class HttpCli(object): if doctxt is not None: j2a["doc"] = doctxt + dirs.sort(key=itemgetter("name")) + for d in dirs: d["name"] += "/" - dirs.sort(key=itemgetter("name")) - if is_opds: # OpenSearch Description format requires a full-qualified URL and a "Short Name" under 16 characters # which will be the longname truncated in the template. diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index 87f96954..ee71d781 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -3760,7 +3760,7 @@ function sortfiles(nodes) { if ((v + '').indexOf('')[1]; else if (name == "href" && v) - v = uricom_dec(v); + v = uri2txt(v, true); nodes[b]._sv = v } @@ -7873,7 +7873,7 @@ var treectl = (function () { delete res['a']; var keys = Object.keys(res); for (var a = 0; a < keys.length; a++) - keys[a] = [uricom_dec(keys[a]), keys[a]]; + keys[a] = [uri2txt(keys[a]), keys[a]]; if (ENATSORT) keys.sort(function (a, b) { return NATSORT.compare(a[0], b[0]); }); diff --git a/copyparty/web/util.js b/copyparty/web/util.js index 8870f22e..fbda90e4 100644 --- a/copyparty/web/util.js +++ b/copyparty/web/util.js @@ -877,6 +877,16 @@ function url_enc(txt) { return ret.join('/'); } +function uri2txt(txt, unslash) { + try { + txt = decodeURIComponent(txt.split('?')[0]); + } + catch (ex) { + console.log("ucd-err [" + txt + "]"); + } + return unslash ? txt.replace(/\/$/, '') : txt; +} + function uricom_dec(txt) { try {