a09fbb8e by Adam Heath

Use regex when looking for attribute values with quotes.

1 parent 458e87da
...@@ -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
......