Improve parseQueryParams regex
This commit is contained in:
parent
0f4aaa4779
commit
986ab1d35a
|
@ -113,29 +113,20 @@ module MongoDBModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
parseQueryParams(params: string, mode: string) {
|
parseQueryParams(params: string, mode: string) {
|
||||||
let queryParams = params.split(/(?<=(},)).*{/g)
|
let queryParams = params.split(/(?<=}),[\n\s]*(?={)/g)
|
||||||
let group1 = queryParams[0]
|
let group1 = queryParams[0] ? JSON.parse(queryParams[0]) : {}
|
||||||
let group2 = queryParams[2]
|
let group2 = queryParams[1] ? JSON.parse(queryParams[1]) : {}
|
||||||
let group3 = queryParams[4]
|
let group3 = queryParams[2] ? JSON.parse(queryParams[2]) : {}
|
||||||
if (group1) {
|
|
||||||
group1 = JSON.parse(group1.replace(/,+$/, ""))
|
|
||||||
}
|
|
||||||
if (group2) {
|
|
||||||
group2 = JSON.parse("{" + group2.replace(/,+$/, ""))
|
|
||||||
}
|
|
||||||
if (group3) {
|
|
||||||
group3 = JSON.parse("{" + group3.replace(/,+$/, ""))
|
|
||||||
}
|
|
||||||
if (mode === "update") {
|
if (mode === "update") {
|
||||||
return {
|
return {
|
||||||
filter: group1,
|
filter: group1,
|
||||||
update: group2,
|
update: group2,
|
||||||
options: group3 ?? {},
|
options: group3,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
filter: group1,
|
filter: group1,
|
||||||
options: group2 ?? {},
|
options: group2,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue