chore(complex-matcher/StringNode): bind lcValue to match
This commit is contained in:
parent
93037ee44f
commit
e58d56a656
@ -173,25 +173,26 @@ export class Property extends Node {
|
|||||||
const escapeChar = char => '\\' + char
|
const escapeChar = char => '\\' + char
|
||||||
const formatString = value =>
|
const formatString = value =>
|
||||||
Number.isNaN(+value)
|
Number.isNaN(+value)
|
||||||
? isRawString(value) ? value : `"${value.replace(/\\|"/g, escapeChar)}"`
|
? isRawString(value)
|
||||||
|
? value
|
||||||
|
: `"${value.replace(/\\|"/g, escapeChar)}"`
|
||||||
: `"${value}"`
|
: `"${value}"`
|
||||||
|
|
||||||
export class StringNode extends Node {
|
export class StringNode extends Node {
|
||||||
constructor (value) {
|
constructor (value) {
|
||||||
super()
|
super()
|
||||||
|
|
||||||
this.lcValue = value.toLowerCase()
|
|
||||||
this.value = value
|
this.value = value
|
||||||
|
|
||||||
// should not be enumerable for the tests
|
// should not be enumerable for the tests
|
||||||
Object.defineProperty(this, 'match', {
|
Object.defineProperty(this, 'match', {
|
||||||
value: this.match.bind(this),
|
value: this.match.bind(this, value.toLowerCase()),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
match (value) {
|
match (lcValue, value) {
|
||||||
if (typeof value === 'string') {
|
if (typeof value === 'string') {
|
||||||
return value.toLowerCase().indexOf(this.lcValue) !== -1
|
return value.toLowerCase().indexOf(lcValue) !== -1
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Array.isArray(value) || isPlainObject(value)) {
|
if (Array.isArray(value) || isPlainObject(value)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user