Comparing version 4.0.1 to 4.1.0
@@ -1173,3 +1173,3 @@ var Gt = Object.defineProperty; | ||
if (a === "q" && typeof e.q == "string") { | ||
const i = new RegExp(e.q, "i"), o = (c) => { | ||
const i = Ud(e.q), o = (c) => { | ||
for (const l in c) { | ||
@@ -1227,3 +1227,7 @@ const u = c[l]; | ||
} | ||
class Ud { | ||
function Ud(t) { | ||
const n = t.trim().replace(/[.*+?^${}()|[\]\\]/g, "\\$&").split(" ").map((i) => `(${i})`).join("|"); | ||
return new RegExp(n, "i"); | ||
} | ||
class Gd { | ||
constructor(e) { | ||
@@ -1308,3 +1312,3 @@ p(this, "obj", null); | ||
} | ||
class Gd { | ||
class Kd { | ||
constructor({ | ||
@@ -1334,3 +1338,3 @@ data: e, | ||
}) | ||
) : this.addSingle(r, new Ud(a)); | ||
) : this.addSingle(r, new Gd(a)); | ||
} | ||
@@ -1408,3 +1412,3 @@ } | ||
p(this, "database"); | ||
this.baseUrl = e, this.defaultQuery = r, this.middlewares = n || [], a ? this.database = a : this.database = new Gd(s); | ||
this.baseUrl = e, this.defaultQuery = r, this.middlewares = n || [], a ? this.database = a : this.database = new Kd(s); | ||
} | ||
@@ -1778,3 +1782,3 @@ /** | ||
} | ||
const qd = (t) => new Bt(t).getHandler(), zd = Bt; | ||
const zd = (t) => new Bt(t).getHandler(), Vd = Bt; | ||
class Ut { | ||
@@ -1837,4 +1841,4 @@ constructor({ | ||
} | ||
const Vd = (t) => new Ut(t).getHandler(), Jd = Ut; | ||
class Kd { | ||
const Jd = (t) => new Ut(t).getHandler(), Qd = Ut; | ||
class Hd { | ||
constructor({ server: e, ...r }) { | ||
@@ -1874,3 +1878,3 @@ p(this, "server"); | ||
} | ||
const Qd = (t) => new Kd(t).getHandler(), Wd = (t) => (e, r) => new Promise((a) => { | ||
const Wd = (t) => new Hd(t).getHandler(), Xd = (t) => (e, r) => new Promise((a) => { | ||
setTimeout(() => { | ||
@@ -1882,15 +1886,15 @@ a(r(e)); | ||
ot as Collection, | ||
Gd as Database, | ||
Kd as Database, | ||
Ut as FetchMockAdapter, | ||
Jd as FetchServer, | ||
Kd as MswAdapter, | ||
zd as Server, | ||
Qd as FetchServer, | ||
Hd as MswAdapter, | ||
Vd as Server, | ||
_e as SimpleRestServer, | ||
Ud as Single, | ||
Gd as Single, | ||
Bt as SinonAdapter, | ||
Vd as getFetchMockHandler, | ||
Qd as getMswHandler, | ||
qd as getSinonHandler, | ||
Wd as withDelay | ||
Jd as getFetchMockHandler, | ||
Wd as getMswHandler, | ||
zd as getSinonHandler, | ||
Xd as withDelay | ||
}; | ||
//# sourceMappingURL=fakerest.min.js.map |
{ | ||
"name": "fakerest", | ||
"version": "4.0.1", | ||
"version": "4.1.0", | ||
"repository": "https://github.com/marmelab/FakeRest", | ||
@@ -5,0 +5,0 @@ "description": "Patch XMLHttpRequest to fake a REST server based on JSON data. ", |
@@ -406,2 +406,10 @@ import { Collection } from './Collection.ts'; | ||
]); | ||
expect( | ||
collection.getAll({ filter: { q: 'hello bar' } }), | ||
).toEqual([ | ||
{ id: 0, a: 'Hello', b: 'world' }, | ||
{ id: 1, a: 'helloworld', b: 'bunny' }, | ||
{ id: 2, a: 'foo', b: 'bar' }, | ||
{ id: 3, a: { b: 'bar' } }, | ||
]); | ||
}); | ||
@@ -408,0 +416,0 @@ |
@@ -444,3 +444,3 @@ import get from 'lodash/get.js'; | ||
if (key === 'q' && typeof filter.q === 'string') { | ||
const regex = new RegExp(filter.q, 'i'); | ||
const regex = buildRegexSearch(filter.q); | ||
@@ -560,1 +560,20 @@ const filterWithQuery = < | ||
} | ||
function buildRegexSearch(input: string) { | ||
// Trim the input to remove leading and trailing whitespace | ||
const trimmedInput = input.trim(); | ||
// Escape special characters in the input to prevent regex injection | ||
const escapedInput = trimmedInput.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); | ||
// Split the input into words | ||
const words = escapedInput.split(' '); | ||
// Create a regex pattern to match any of the words | ||
const pattern = words.map((word) => `(${word})`).join('|'); | ||
// Create a new RegExp object with the pattern, case insensitive | ||
const regex = new RegExp(pattern, 'i'); | ||
return regex; | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1453548
12311