Fix duplicate entry in URL filtering dialog: https://github.com/gorhill/uBlock/issues/3401

This commit is contained in:
Raymond Hill 2018-12-21 10:09:29 -05:00
parent 21593dbfdd
commit 2849dbb805
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 12 additions and 10 deletions

View File

@ -1054,26 +1054,28 @@ var netFilteringManager = (function() {
}; };
// Build list of candidate URLs // Build list of candidate URLs
var createTargetURLs = function(url) { const createTargetURLs = function(url) {
var urls = []; const urls = [];
var matches = reRFC3986.exec(url); const matches = reRFC3986.exec(url);
if ( matches === null || !matches[1] || !matches[2] ) { if ( matches === null || !matches[1] || !matches[2] ) {
return urls; return urls;
} }
// Shortest URL for a valid URL filtering rule // Shortest URL for a valid URL filtering rule
var rootURL = matches[1] + matches[2]; const rootURL = matches[1] + matches[2];
urls.unshift(rootURL); urls.unshift(rootURL);
var path = matches[3] || ''; const path = matches[3] || '';
var pos = path.charAt(0) === '/' ? 1 : 0; let pos = path.charAt(0) === '/' ? 1 : 0;
while ( pos < path.length ) { while ( pos < path.length ) {
pos = path.indexOf('/', pos + 1); pos = path.indexOf('/', pos);
if ( pos === -1 ) { if ( pos === -1 ) {
pos = path.length; 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] || ''; const query = matches[4] || '';
if ( query !== '') { if ( query !== '' ) {
urls.unshift(rootURL + path + query); urls.unshift(rootURL + path + query);
} }
return urls; return urls;