fix: improve directory sorting

This commit is contained in:
NecRaul 2026-06-17 00:04:10 +04:00
parent efa43f891b
commit fcdec17f36
No known key found for this signature in database
3 changed files with 14 additions and 4 deletions

View file

@ -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.

View file

@ -3760,7 +3760,7 @@ function sortfiles(nodes) {
if ((v + '').indexOf('<a ') === 0)
v = v.split('>')[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]); });

View file

@ -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 {