From 2849dbb805947948fdb34a58b11090d619301d98 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Fri, 21 Dec 2018 10:09:29 -0500 Subject: [PATCH] Fix duplicate entry in URL filtering dialog: https://github.com/gorhill/uBlock/issues/3401 --- src/js/logger-ui.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/js/logger-ui.js b/src/js/logger-ui.js index 2014635e3..701c2465e 100644 --- a/src/js/logger-ui.js +++ b/src/js/logger-ui.js @@ -1054,26 +1054,28 @@ var netFilteringManager = (function() { }; // Build list of candidate URLs - var createTargetURLs = function(url) { - var urls = []; - var matches = reRFC3986.exec(url); + const createTargetURLs = function(url) { + const urls = []; + const matches = reRFC3986.exec(url); if ( matches === null || !matches[1] || !matches[2] ) { return urls; } // Shortest URL for a valid URL filtering rule - var rootURL = matches[1] + matches[2]; + const rootURL = matches[1] + matches[2]; urls.unshift(rootURL); - var path = matches[3] || ''; - var pos = path.charAt(0) === '/' ? 1 : 0; + const path = matches[3] || ''; + let pos = path.charAt(0) === '/' ? 1 : 0; while ( pos < path.length ) { - pos = path.indexOf('/', pos + 1); + pos = path.indexOf('/', pos); if ( pos === -1 ) { pos = path.length; + } else { + pos += 1; } - urls.unshift(rootURL + path.slice(0, pos + 1)); + urls.unshift(rootURL + path.slice(0, pos)); } - var query = matches[4] || ''; - if ( query !== '') { + const query = matches[4] || ''; + if ( query !== '' ) { urls.unshift(rootURL + path + query); } return urls;