diff --git a/removetracking.go b/removetracking.go index f37d4ee..ea1f8a8 100644 --- a/removetracking.go +++ b/removetracking.go @@ -18,25 +18,14 @@ func removeTracking(input string) (output string, err error) { return input, err } - // Remove the URL part starting with "?utm_", which is - // used for tracking purposes. - output = strings.Split(resp.Request.URL.String(), "?utm_")[0] + output = resp.Request.URL.String() - // Remove the URL part starting with "?wt_", which is - // used for Webtrekk tracking. - output = strings.Split(output, "?wt_")[0] + // Remove the URL part starting with known tracking parameters. + trackingParameters := [6]string{"?utm_", "?wt_", "#ref=", "?ref=", "?pk_", "?source="} - // Remove the URL part starting with "#ref=", which is - // used for tracking the referer by some feeds. - output = strings.Split(output, "#ref=")[0] - - // Remove the URL part starting with "?ref=", which is - // used for tracking the referer by some feeds. - output = strings.Split(output, "?ref=")[0] - - // Remove the URL part starting with "?pk_", which is - // used for tracking purposes. - output = strings.Split(output, "?pk_")[0] + for _, trackingParameter := range trackingParameters { + output = strings.Split(output, trackingParameter)[0] + } return output, err }