1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-07 03:12:33 +01:00

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`
This commit is contained in:
Raymond Hill 2019-06-25 17:09:04 -04:00
parent 9065bbdd48
commit d1df2b5e73
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -296,7 +296,7 @@ const mergeStrings = function(urls) {
if ( diff[0] !== 0 ) { if ( diff[0] !== 0 ) {
result.push('*'); result.push('*');
} else { } 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 // 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 !== '' ) { if ( typeof elem.srcset === 'string' && elem.srcset !== '' ) {
const ss = []; const ss = [];
for ( let s of elem.srcset.split(',') ) { for ( let s of elem.srcset.split(',') ) {
s = s.trim();
const pos = s.indexOf(' '); const pos = s.indexOf(' ');
if ( pos !== -1 ) { s = s.slice(0, pos); } if ( pos !== -1 ) { s = s.slice(0, pos); }
const parsedURL = new URL(s, document.baseURI); const parsedURL = new URL(s, document.baseURI);