diff --git a/libtransmission/announce-list.cc b/libtransmission/announce-list.cc index 2af412902..c7c7a9b59 100644 --- a/libtransmission/announce-list.cc +++ b/libtransmission/announce-list.cc @@ -86,6 +86,7 @@ bool tr_announce_list::add(std::string_view announce_url_sv, tr_tracker_tier_t t tracker.id = nextUniqueId(); tracker.host = fmt::format(FMT_STRING("{:s}:{:d}"), announce->host, announce->port); tracker.sitename = announce->sitename; + tracker.query = announce->query; if (auto const scrape_str = announceToScrape(announce_url_sv); scrape_str) { @@ -224,7 +225,8 @@ bool tr_announce_list::canAdd(tr_url_parsed_t const& announce) auto const tracker_parsed = tr_urlParse(tracker_announce); return tracker_parsed->scheme == announce.scheme && tracker_parsed->host == announce.host && - tracker_parsed->port == announce.port && tracker_parsed->path == announce.path; + tracker_parsed->port == announce.port && tracker_parsed->path == announce.path && + tracker_parsed->query == announce.query; }; return std::none_of(std::begin(trackers_), std::end(trackers_), is_same); } diff --git a/libtransmission/announce-list.h b/libtransmission/announce-list.h index 46790e5d7..07d900c79 100644 --- a/libtransmission/announce-list.h +++ b/libtransmission/announce-list.h @@ -28,6 +28,7 @@ public: tr_interned_string scrape; tr_interned_string host; // 'example.org:80' tr_interned_string sitename; // 'example' + tr_interned_string query; // 'name=ferret' tr_tracker_tier_t tier = 0; tr_tracker_id_t id = 0; diff --git a/tests/libtransmission/announce-list-test.cc b/tests/libtransmission/announce-list-test.cc index db6b8cf8d..27626ab37 100644 --- a/tests/libtransmission/announce-list-test.cc +++ b/tests/libtransmission/announce-list-test.cc @@ -272,6 +272,18 @@ TEST_F(AnnounceListTest, canReplace) EXPECT_EQ(Announce2, announce_list.at(0).announce.sv()); } +TEST_F(AnnounceListTest, canReplaceWithDiffQuery) +{ + auto constexpr Tier = tr_tracker_tier_t{ 1 }; + auto constexpr Announce1 = "https://www.example.com/1/announce"sv; + auto constexpr Announce2 = "https://www.example.com/2/announce?pass=1999"sv; + + auto announce_list = tr_announce_list{}; + EXPECT_TRUE(announce_list.add(Announce1, Tier)); + EXPECT_TRUE(announce_list.replace(announce_list.at(0).id, Announce2)); + EXPECT_EQ(Announce2, announce_list.at(0).announce.sv()); +} + TEST_F(AnnounceListTest, canNotReplaceInvalidId) { auto constexpr Tier = tr_tracker_tier_t{ 1 };