Skip to content

Commit 58f80c9

Browse files
committed
fix: convert routes verb to lower case for both custom and sails routerr:bind event
1 parent 2c43b76 commit 58f80c9

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

index.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ module.exports = (sails: Sails.Sails): Sails.Hook<SwaggerGenerator> => {
3737
initialize: function (next): void {
3838

3939
// https://github.com/balderdashy/sails/blob/master/lib/EVENTS.md#routerbind
40-
sails.on('router:bind', (routeObj) => {
41-
if (!routes.find(route => route.path === routeObj.path && route.verb === routeObj.verb)) {
40+
sails.on('router:bind', routeObj => {
41+
if (!routes.find(route => route.path === routeObj.path && route.verb === routeObj.verb.toLowerCase())) {
42+
routeObj.verb = routeObj.verb.toLowerCase();
4243
routes.push(routeObj);
4344
}
4445
});

lib/parsers.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ export const parseCustomRoutes = (sailsConfig: Sails.Config): Array<ParsedCustom
5959
for (const routeAddress in routes) {
6060
// Parse 1: Route Address
6161
// see https://sailsjs.com/documentation/concepts/routes/custom-routes#?route-address
62-
let [verb, path] = routeAddress.split(/\s+/)
62+
let [verb = 'get', path] = routeAddress.split(/\s+/)
63+
verb = verb.toLowerCase();
6364
if (!path) {
6465
path = verb
6566
verb = 'all'

0 commit comments

Comments
 (0)