mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-11 15:56:17 -07:00
Merge pull request #19069 from Chocobo1/sort
WebUI: use natural sort on tracker list
This commit is contained in:
commit
83e6afcb71
3 changed files with 14 additions and 18 deletions
|
@ -116,8 +116,7 @@ function getHost(url) {
|
|||
|
||||
try {
|
||||
// hack: URL can not get hostname from udp protocol
|
||||
url = url.replace(/^udp:/, 'https:');
|
||||
const parsedUrl = new URL(url);
|
||||
const parsedUrl = new URL(url.replace(/^udp:/, 'https:'));
|
||||
// host: "example.com:8443"
|
||||
// hostname: "example.com"
|
||||
const host = parsedUrl.hostname;
|
||||
|
@ -623,16 +622,12 @@ window.addEvent('load', function() {
|
|||
|
||||
// Sort trackers by hostname
|
||||
const sortedList = [...trackerList.entries()].sort((left, right) => {
|
||||
const leftHost = getHost(left[1].url.toLowerCase());
|
||||
const rightHost = getHost(right[1].url.toLowerCase());
|
||||
if (leftHost < rightHost)
|
||||
return -1;
|
||||
if (leftHost > rightHost)
|
||||
return 1;
|
||||
return 0;
|
||||
const leftHost = getHost(left[1].url);
|
||||
const rightHost = getHost(right[1].url);
|
||||
return window.qBittorrent.Misc.naturalSortCollator.compare(leftHost, rightHost);
|
||||
});
|
||||
for (const [hash, tracker] of sortedList) {
|
||||
trackerFilterList.appendChild(createLink(hash, getHost(tracker.url) + ' (%1)', tracker.torrents.length));
|
||||
trackerFilterList.appendChild(createLink(hash, (getHost(tracker.url) + ' (%1)'), tracker.torrents.length));
|
||||
}
|
||||
|
||||
highlightSelectedTracker();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue