From d1df2b5e73953883c02368a245e423f388507378 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Tue, 25 Jun 2019 17:09:04 -0400 Subject: [PATCH] Fix merging multiple URls in element picker Related discussion: - https://www.reddit.com/r/uBlockOrigin/comments/c5do7w/ Fixed: - Expect the differ can return the first input as is when there is no difference between the two items. - Better deal with extraneous whitespaces in `srcset` --- src/js/scriptlets/element-picker.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/js/scriptlets/element-picker.js b/src/js/scriptlets/element-picker.js index 1cb5ecb2e..864a15b53 100644 --- a/src/js/scriptlets/element-picker.js +++ b/src/js/scriptlets/element-picker.js @@ -296,7 +296,7 @@ const mergeStrings = function(urls) { if ( diff[0] !== 0 ) { result.push('*'); } else { - result.push(diff[1].charAt(0)); + result.push(diff[1].replace(/\n+/g, '')); } } // Keep usage of wildcards to a sane level, too many of them can cause @@ -343,6 +343,7 @@ const resourceURLFromElement = function(elem) { if ( typeof elem.srcset === 'string' && elem.srcset !== '' ) { const ss = []; for ( let s of elem.srcset.split(',') ) { + s = s.trim(); const pos = s.indexOf(' '); if ( pos !== -1 ) { s = s.slice(0, pos); } const parsedURL = new URL(s, document.baseURI);