Skip to content

Commit

Permalink
Fix merging multiple URls in element picker
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
gorhill committed Jun 25, 2019
1 parent 9065bbd commit d1df2b5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/js/scriptlets/element-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit d1df2b5

Please sign in to comment.