redis-om
Advanced tools
Comparing version 0.4.1 to 0.4.2
@@ -666,2 +666,4 @@ import { createClient, createCluster, RediSearchSchema, SearchOptions } from 'redis'; | ||
protected escapePunctuation(value: string): string; | ||
/** @internal */ | ||
protected escapePunctuationAndSpaces(value: string): string; | ||
} | ||
@@ -668,0 +670,0 @@ |
@@ -819,9 +819,13 @@ "use strict"; | ||
const negationPortion = this.negated ? "-" : ""; | ||
const fieldPortion = this.escapePunctuation(this.field.name); | ||
const fieldPortion = this.escapePunctuationAndSpaces(this.field.name); | ||
return `(${negationPortion}@${fieldPortion}:${valuePortion})`; | ||
} | ||
escapePunctuation(value) { | ||
const matchPunctuation = /[,.<>{}[\]"':;!@#$%^&()\-+=~|/\\ ]/g; | ||
const matchPunctuation = /[,.?<>{}[\]"':;!@#$%^&()\-+=~|/\\]/g; | ||
return value.replace(matchPunctuation, "\\$&"); | ||
} | ||
escapePunctuationAndSpaces(value) { | ||
const matchPunctuation = /[,.?<>{}[\]"':;!@#$%^&()\-+=~|/\\ ]/g; | ||
return value.replace(matchPunctuation, "\\$&"); | ||
} | ||
}; | ||
@@ -847,4 +851,3 @@ | ||
toString() { | ||
const matchPunctuation = /[,.<>{}[\]"':;!@#$%^&()\-+=~| ]/g; | ||
const escapedValue = this.value.map((s) => s.replace(matchPunctuation, "\\$&")).join("|"); | ||
const escapedValue = this.value.map((s) => this.escapePunctuationAndSpaces(s)).join("|"); | ||
return this.buildQuery(`{${escapedValue}}`); | ||
@@ -1087,3 +1090,3 @@ } | ||
toString() { | ||
const escapedValue = this.escapePunctuation(this.value); | ||
const escapedValue = this.escapePunctuationAndSpaces(this.value); | ||
return this.buildQuery(`{${escapedValue}}`); | ||
@@ -1140,4 +1143,3 @@ } | ||
toString() { | ||
const matchPunctuation = /[,.<>{}[\]"':;!@#$%^&()\-+=~|]/g; | ||
const escapedValue = this.value.replace(matchPunctuation, "\\$&"); | ||
const escapedValue = this.escapePunctuation(this.value); | ||
if (this.exactValue) { | ||
@@ -1144,0 +1146,0 @@ return this.buildQuery(`"${escapedValue}"`); |
{ | ||
"name": "redis-om", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "Object mapping, and more, for Redis and Node.js. Written in TypeScript.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
378365
3329