From e58d56a6568b97181d91c90a1b35eda57207eb3c Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Wed, 18 Jul 2018 12:33:39 +0200 Subject: [PATCH] chore(complex-matcher/StringNode): bind lcValue to match --- packages/complex-matcher/src/index.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/complex-matcher/src/index.js b/packages/complex-matcher/src/index.js index ba11bcc29..0badce969 100644 --- a/packages/complex-matcher/src/index.js +++ b/packages/complex-matcher/src/index.js @@ -173,25 +173,26 @@ export class Property extends Node { const escapeChar = char => '\\' + char const formatString = value => Number.isNaN(+value) - ? isRawString(value) ? value : `"${value.replace(/\\|"/g, escapeChar)}"` + ? isRawString(value) + ? value + : `"${value.replace(/\\|"/g, escapeChar)}"` : `"${value}"` export class StringNode extends Node { constructor (value) { super() - this.lcValue = value.toLowerCase() this.value = value // should not be enumerable for the tests 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') { - return value.toLowerCase().indexOf(this.lcValue) !== -1 + return value.toLowerCase().indexOf(lcValue) !== -1 } if (Array.isArray(value) || isPlainObject(value)) {