Skip to content

Commit

Permalink
fixed path param replacement regex
Browse files Browse the repository at this point in the history
  • Loading branch information
moyukhbera committed Apr 10, 2023
1 parent 16fd360 commit aa772fb
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "quick-validate",
"version": "1.0.5",
"version": "1.0.7",
"description": "Express middleware for codeless configuration-driven API validations",
"main": "lib/index.js",
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const setParamRouteValidations = (routesJSON) => {
for (const httpMethod in routesJSON) {
for (const url in routesJSON[httpMethod]) {
if (url.indexOf(":") > -1) {
paramAuthRoutes[httpMethod][url.replace(/:[a-zA-Z0-9-_]+/g, "[a-zA-Z0-9-]+")] = routesJSON[httpMethod][url];
paramAuthRoutes[httpMethod][url.replace(/:[a-zA-Z0-9-_]+/g, "[a-zA-Z0-9-_]+")] = routesJSON[httpMethod][url];
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ test("setParamRouteValidations replaces param variable with regex", () => {
}
})).toStrictEqual({
"GET": {
"/product/[a-zA-Z0-9-]+": {
"/product/[a-zA-Z0-9-_]+": {

}
},
Expand Down
2 changes: 1 addition & 1 deletion src/quickValidate.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export const validate = (obj, validationConfig, reqPartName) => {
}

if (obj[fieldName] !== false && obj[fieldName] !== "" && !obj[fieldName]) {
return;
continue;
}

for (let key in fieldValidations) {
Expand Down

0 comments on commit aa772fb

Please sign in to comment.