Fix logger's reverse-lookup of selectors with no \w characters

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1139
This commit is contained in:
Raymond Hill 2020-07-03 14:32:12 -04:00
parent 941898e54e
commit d1715fb19f
No known key found for this signature in database
GPG key ID: 25E1490B761470C2

View file

@ -124,7 +124,9 @@ const fromCosmeticFilter = function(details) {
const hostname = details.hostname; const hostname = details.hostname;
// The longer the needle, the lower the number of false positives. // The longer the needle, the lower the number of false positives.
const needle = selector.match(/\w+/g).reduce(function(a, b) { // https://github.com/uBlockOrigin/uBlock-issues/issues/1139
// Mind that there is no guarantee a selector has `\w` characters.
const needle = selector.match(/\w+|^.*$/g).reduce(function(a, b) {
return a.length > b.length ? a : b; return a.length > b.length ? a : b;
}); });