fix directory sort-order (closes #1119) (#1528);

folders sorted incorrectly due to the trailing slash,
for example `a/` vs. `a b/`
This commit is contained in:
NecRaul 2026-06-17 02:25:08 +04:00 committed by GitHub
parent e017b1bc6e
commit d33d11321f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 4 deletions

View file

@ -7470,11 +7470,11 @@ class HttpCli(object):
if doctxt is not None: if doctxt is not None:
j2a["doc"] = doctxt j2a["doc"] = doctxt
dirs.sort(key=itemgetter("name"))
for d in dirs: for d in dirs:
d["name"] += "/" d["name"] += "/"
dirs.sort(key=itemgetter("name"))
if is_opds: if is_opds:
# OpenSearch Description format requires a full-qualified URL and a "Short Name" under 16 characters # OpenSearch Description format requires a full-qualified URL and a "Short Name" under 16 characters
# which will be the longname truncated in the template. # which will be the longname truncated in the template.

View file

@ -3760,7 +3760,7 @@ function sortfiles(nodes) {
if ((v + '').indexOf('<a ') === 0) if ((v + '').indexOf('<a ') === 0)
v = v.split('>')[1]; v = v.split('>')[1];
else if (name == "href" && v) else if (name == "href" && v)
v = uricom_dec(v); v = uri2txt(v, true);
nodes[b]._sv = v nodes[b]._sv = v
} }
@ -7873,7 +7873,7 @@ var treectl = (function () {
delete res['a']; delete res['a'];
var keys = Object.keys(res); var keys = Object.keys(res);
for (var a = 0; a < keys.length; a++) 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) if (ENATSORT)
keys.sort(function (a, b) { return NATSORT.compare(a[0], b[0]); }); keys.sort(function (a, b) { return NATSORT.compare(a[0], b[0]); });

View file

@ -877,6 +877,16 @@ function url_enc(txt) {
return ret.join('/'); 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) { function uricom_dec(txt) {
try { try {