From e001144d1a5d47aa63ed07d5d7647148db69a8e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20R=C3=B6bert?= Date: Mon, 25 Jun 2018 21:58:07 +0200 Subject: [PATCH] Core fix #71 The splitt function for the fields was a greedy function and splitt at the last question mark, but it should splitt at the last question mark. So now the splitt function is a non-greedy function. --- clearurls.js | 8 +++++++- manifest.json | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/clearurls.js b/clearurls.js index b8514be..a7c03ad 100644 --- a/clearurls.js +++ b/clearurls.js @@ -364,7 +364,13 @@ function start(items) */ if(existsFields(url)) { - fields = url.replace(new RegExp(".*\\?", "i"), ""); + /** + * It must be non-greedy, because by default .* will match + * all ? chars. So the replace function delete everything + * before the last ?. With adding a ? on the quantifier *, + * we fixed this problem. + */ + fields = url.replace(new RegExp(".*?\\?", "i"), ""); for (var i = 0; i < rules.length; i++) { var beforReplace = fields; diff --git a/manifest.json b/manifest.json index f3e1ec5..e797729 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "ClearURLs", - "version": "1.3.3.3", + "version": "1.3.3.4", "author": "Kevin R.", "description": "Remove tracking elements form URLs.", "homepage_url": "https://gitlab.com/KevinRoebert/ClearUrls",