@@ -14,8 +14,8 @@ func TestRemoveTrackingParams(t *testing.T) {
1414 name string
1515 input string
1616 expected string
17- baseUrl string
18- feedUrl string
17+ baseURL string
18+ feedURL string
1919 strictComparison bool
2020 }{
2121 {
@@ -67,62 +67,69 @@ func TestRemoveTrackingParams(t *testing.T) {
6767 {
6868 name : "ref parameter for another url" ,
6969 input : "https://example.com/page?ref=test.com" ,
70- baseUrl : "https://example.com/page" ,
70+ baseURL : "https://example.com/page" ,
7171 expected : "https://example.com/page?ref=test.com" ,
7272 },
7373 {
7474 name : "ref parameter for feed url" ,
7575 input : "https://example.com/page?ref=feed.com" ,
76- baseUrl : "https://example.com/page" ,
76+ baseURL : "https://example.com/page" ,
7777 expected : "https://example.com/page" ,
78- feedUrl : "http://feed.com" ,
78+ feedURL : "http://feed.com" ,
7979 },
8080 {
8181 name : "ref parameter for site url" ,
8282 input : "https://example.com/page?ref=example.com" ,
83- baseUrl : "https://example.com/page" ,
83+ baseURL : "https://example.com/page" ,
8484 expected : "https://example.com/page" ,
8585 },
8686 {
8787 name : "ref parameter for base url" ,
8888 input : "https://example.com/page?ref=example.com" ,
8989 expected : "https://example.com/page" ,
90- baseUrl : "https://example.com" ,
91- feedUrl : "https://feedburned.com/example" ,
90+ baseURL : "https://example.com" ,
91+ feedURL : "https://feedburned.com/example" ,
9292 },
9393 {
9494 name : "ref parameter for base url on subdomain" ,
9595 input : "https://blog.exploits.club/some-path?ref=blog.exploits.club" ,
9696 expected : "https://blog.exploits.club/some-path" ,
97- baseUrl : "https://blog.exploits.club/some-path" ,
98- feedUrl : "https://feedburned.com/exploit.club" ,
97+ baseURL : "https://blog.exploits.club/some-path" ,
98+ feedURL : "https://feedburned.com/exploit.club" ,
9999 },
100100 {
101101 name : "Non-standard URL parameter with no tracker" ,
102102 input : "https://example.com/foo.jpg?crop/1420x708/format/webp" ,
103103 expected : "https://example.com/foo.jpg?crop/1420x708/format/webp" ,
104- baseUrl : "https://example.com/page" ,
104+ baseURL : "https://example.com/page" ,
105105 strictComparison : true ,
106106 },
107107 {
108108 name : "Invalid URL" ,
109109 input : "https://example|org/" ,
110- baseUrl : "https://example.com/page" ,
110+ baseURL : "https://example.com/page" ,
111111 expected : "" ,
112112 },
113113 {
114114 name : "Non-HTTP URL" ,
115115 input :
"mailto:[email protected] " ,
116116 expected :
"mailto:[email protected] " ,
117- baseUrl : "https://example.com/page" ,
117+ baseURL : "https://example.com/page" ,
118+ strictComparison : true ,
119+ },
120+ {
121+ name : "Matomo tracking URL" ,
122+ input : "https://example.com/?mtm_campaign=2020_august_promo&mtm_source=newsletter&mtm_medium=email&mtm_content=primary-cta" ,
123+ expected : "https://example.com/" ,
124+ baseURL : "https://example.com" ,
118125 strictComparison : true ,
119126 },
120127 }
121128
122129 for _ , tt := range tests {
123130 t .Run (tt .name , func (t * testing.T ) {
124- parsedBaseUrl , _ := url .Parse (tt .baseUrl )
125- parsedFeedUrl , _ := url .Parse (tt .feedUrl )
131+ parsedBaseUrl , _ := url .Parse (tt .baseURL )
132+ parsedFeedUrl , _ := url .Parse (tt .feedURL )
126133 parsedInputUrl , _ := url .Parse (tt .input )
127134 result , err := RemoveTrackingParameters (parsedBaseUrl , parsedFeedUrl , parsedInputUrl )
128135 if tt .expected == "" {
0 commit comments