mirror of
https://salsa.debian.org/mdosch/feed-to-muc.git
synced 2024-11-14 02:06:50 +01:00
35 lines
848 B
Go
35 lines
848 B
Go
|
/* 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]
|
||
|
|
||
|
return output, err
|
||
|
}
|