Use regex when looking for attribute values with quotes.
Showing
1 changed file
with
1 additions
and
1 deletions
... | @@ -114,7 +114,7 @@ const compileMatcher = (ast: AST, selector: string): MatcherProducer => { | ... | @@ -114,7 +114,7 @@ const compileMatcher = (ast: AST, selector: string): MatcherProducer => { |
114 | 114 | ||
115 | const getAttrValueMatch = (value: string, operator: string = '=', caseSensitive: boolean): AttrValueMatch => { | 115 | const getAttrValueMatch = (value: string, operator: string = '=', caseSensitive: boolean): AttrValueMatch => { |
116 | if (value === undefined) return (attrValue) => attrValue !== undefined | 116 | if (value === undefined) return (attrValue) => attrValue !== undefined |
117 | if (value[ 0 ] === '"' || value[ 0 ] === '\'') value = value.substring(1, value.length - 1) | 117 | if (value.match(/^(['"]).*\1$/)) value = value.substring(1, value.length - 1) |
118 | const isCaseInsensitive = caseSensitive === 'i' | 118 | const isCaseInsensitive = caseSensitive === 'i' |
119 | if (isCaseInsensitive) value = value.toLowerCase() | 119 | if (isCaseInsensitive) value = value.toLowerCase() |
120 | const adjustMatcher = (matcher) => isCaseInsensitive ? (attrValue) => matcher(attrValue.toLowerCase()) : matcher | 120 | const adjustMatcher = (matcher) => isCaseInsensitive ? (attrValue) => matcher(attrValue.toLowerCase()) : matcher | ... | ... |
-
Please register or sign in to post a comment