From 4ac25a50ede9526f89e0fa54bbdabe83e8ec72aa Mon Sep 17 00:00:00 2001 From: Mengyang Li Date: Fri, 6 Aug 2021 21:25:07 -0700 Subject: [PATCH] WebUI: group trackers by hostname (#15264) Closes #13608. --- src/webui/www/private/scripts/client.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/webui/www/private/scripts/client.js b/src/webui/www/private/scripts/client.js index 997fa78bb..2ef2f657d 100644 --- a/src/webui/www/private/scripts/client.js +++ b/src/webui/www/private/scripts/client.js @@ -96,6 +96,10 @@ function genHash(string) { return hash; } +function getTrackerHost(url) { + return new URL(url).hostname; +} + function getSyncMainDataInterval() { return customSyncMainDataInterval ? customSyncMainDataInterval : serverSyncMainDataInterval; } @@ -622,9 +626,10 @@ window.addEvent('load', function() { if (response['trackers']) { for (const tracker in response['trackers']) { const torrents = response['trackers'][tracker]; - const hash = genHash(tracker); + const host = getTrackerHost(tracker); + const hash = genHash(host); trackerList.set(hash, { - url: tracker, + url: host, torrents: torrents }); }