2018-08-03 11:02:31 +02:00
|
|
|
/* Copyright 2018 Martin Dosch
|
|
|
|
Licensed under the "MIT License" */
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Remove tracking parameter from URLs
|
|
|
|
func removeTracking(input string) (output string, err error) {
|
|
|
|
|
|
|
|
// Perfom a get request to get rid of 301 forwarding through
|
|
|
|
// services like feedproxy.google.com.
|
|
|
|
resp, err := http.Get(input)
|
|
|
|
if err != nil {
|
|
|
|
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]
|
|
|
|
|
|
|
|
// 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 "#ref=", which is
|
|
|
|
// used for tracking the referer by some feeds.
|
|
|
|
output = strings.Split(output, "#ref=")[0]
|
|
|
|
|
2018-08-03 14:50:33 +02:00
|
|
|
// Remove the URL part starting with "?ref=", which is
|
|
|
|
// used for tracking the referer by some feeds.
|
|
|
|
output = strings.Split(output, "?ref=")[0]
|
|
|
|
|
2018-08-03 11:02:31 +02:00
|
|
|
return output, err
|
|
|
|
}
|