diff --git a/CHANGELOG.md b/CHANGELOG.md index bbda5f9..9b20179 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.6.6] - 2019-06-14 + +### Compatibility note +- Require Firefox >= 55 +- Require Chrome >= 22 + +### Fixed +- [#171](https://gitlab.com/KevinRoebert/ClearUrls/issues/171) +- [#195](https://gitlab.com/KevinRoebert/ClearUrls/issues/195) + ## [1.6.5] - 2019-06-12 ### Compatibility note diff --git a/clearurls.js b/clearurls.js index 6f7445e..3c89f9c 100644 --- a/clearurls.js +++ b/clearurls.js @@ -72,14 +72,20 @@ function removeFieldsFormURL(provider, pureUrl) }; } + + if(existsFields(url)) { + fields = "?"+extractFileds(url).rmEmpty().join("&"); + } + + if(existsFragments(url)) { + fragments = "#"+extractFragments(url).rmEmpty().join("&"); + } + /** * Only test for matches, if there are fields or fragments that can be cleaned. */ - if(existsFields(url) || existsFragments(url)) + if(fields !== "" || fragments !== "") { - fields = extractFileds(url).rmEmpty().join("&"); - fragments = extractFragments(url).rmEmpty().join("&"); - rules.forEach(function(rule) { var beforReplace = fields; var beforReplaceFragments = fragments; @@ -94,10 +100,10 @@ function removeFieldsFormURL(provider, pureUrl) var tempURL = domain; var tempBeforeURL = domain; - if(fields !== "") tempURL += "?"+fields; - if(fragments !== "") tempURL += "#"+fragments; - if(beforReplace !== "") tempBeforeURL += "?"+beforReplace; - if(beforReplaceFragments !== "") tempBeforeURL += "#"+beforReplaceFragments; + if(fields !== "") tempURL += "?"+fields.replace("?&", "?").replace("?", ""); + if(fragments !== "") tempURL += "#"+fragments.replace("#&","#").replace("#", ""); + if(beforReplace !== "") tempBeforeURL += "?"+beforReplace.replace("?&", "?").replace("?", ""); + if(beforReplaceFragments !== "") tempBeforeURL += "#"+beforReplaceFragments.replace("#&","#").replace("#", ""); pushToLog(tempBeforeURL, tempURL, rule); } @@ -122,10 +128,10 @@ function removeFieldsFormURL(provider, pureUrl) var finalURL = domain; - if(fields !== "") finalURL += "?"+fields; - if(fragments !== "") finalURL += "#"+fragments; + if(fields !== "") finalURL += "?"+fields.replace("?", ""); + if(fragments !== "") finalURL += "#"+fragments.replace("#", ""); - url = finalURL; + url = finalURL.replace(new RegExp("\\?&"), "?").replace(new RegExp("#&"), "#"); } if(provider.isCaneling()){ @@ -363,7 +369,7 @@ function start() * @param {boolean} isActive Is this rule active? */ this.addRule = function(rule, isActive = true) { - rule = "([\\/]|(&|&))*("+rule+"=[^\\/|\\?|&]*)"; + rule = "([\\/|\\?|#]|(&|&))+("+rule+"=[^\\/|\\?|&]*)"; if(isActive) { diff --git a/manifest.json b/manifest.json index 588a7f4..464d59f 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "ClearURLs", - "version": "1.6.5", + "version": "1.6.6", "author": "Kevin R.", "description": "Remove tracking elements form URLs.", "homepage_url": "https://gitlab.com/KevinRoebert/ClearUrls",