1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-09-15 18:57:04 +00:00

fix: do not alter the original URL if there is no tracker parameter

This commit is contained in:
Frédéric Guillot 2024-07-25 21:47:03 -07:00
parent 92f3dc26e4
commit 37309adbc0
2 changed files with 28 additions and 9 deletions

View file

@ -78,14 +78,21 @@ func RemoveTrackingParameters(inputURL string) (string, error) {
}
queryParams := parsedURL.Query()
hasTrackers := false
// Remove tracking parameters
for param := range queryParams {
if trackingParams[strings.ToLower(param)] {
queryParams.Del(param)
hasTrackers = true
}
}
// Do not modify the URL if there are no tracking parameters
if !hasTrackers {
return inputURL, nil
}
parsedURL.RawQuery = queryParams.Encode()
// Remove trailing "?" if query string is empty