fix: announce with query replace bug (#5871)
This commit is contained in:
parent
03ffe42ad4
commit
daff66690a
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 };
|
||||
|
|
Loading…
Reference in New Issue