From c99b61da96a2dbe99be67280169b3f4cf4afc078 Mon Sep 17 00:00:00 2001 From: gorhill Date: Thu, 5 Nov 2015 09:19:45 -0500 Subject: [PATCH] code review: no need to capture in regex --- src/js/cosmetic-filtering.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/js/cosmetic-filtering.js b/src/js/cosmetic-filtering.js index a3b549788..7371a98fb 100644 --- a/src/js/cosmetic-filtering.js +++ b/src/js/cosmetic-filtering.js @@ -728,10 +728,10 @@ FilterContainer.prototype.compileGenericSelector = function(parsed, out) { // Single-CSS rule: no need to test for whether the selector // is valid, the regex took care of this. Most generic selector falls // into that category. - if ( matches[1] === selector ) { + if ( matches[0] === selector ) { out.push( 'c\vlg\v' + - matches[1] + matches[0] ); return; } @@ -739,7 +739,7 @@ FilterContainer.prototype.compileGenericSelector = function(parsed, out) { if ( this.isValidSelector(selector) ) { out.push( 'c\vlg+\v' + - matches[1] + '\v' + + matches[0] + '\v' + selector ); } @@ -774,7 +774,7 @@ FilterContainer.prototype.compileGenericSelector = function(parsed, out) { }; FilterContainer.prototype.reClassOrIdSelector = /^([#.][\w-]+)$/; -FilterContainer.prototype.rePlainSelector = /^([#.][\w-]+)/; +FilterContainer.prototype.rePlainSelector = /^[#.][\w-]+/; FilterContainer.prototype.reHighLow = /^[a-z]*\[(?:alt|title)="[^"]+"\]$/; FilterContainer.prototype.reHighMedium = /^\[href\^="https?:\/\/([^"]{8})[^"]*"\]$/;