Skip to content

Commit

Permalink
fix: convert routes verb to lower case for both custom and sails rout…
Browse files Browse the repository at this point in the history
…err:bind event
  • Loading branch information
theoomoregbee committed May 18, 2020
1 parent 2c43b76 commit 58f80c9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ module.exports = (sails: Sails.Sails): Sails.Hook<SwaggerGenerator> => {
initialize: function (next): void {

// https://github.com/balderdashy/sails/blob/master/lib/EVENTS.md#routerbind
sails.on('router:bind', (routeObj) => {
if (!routes.find(route => route.path === routeObj.path && route.verb === routeObj.verb)) {
sails.on('router:bind', routeObj => {
if (!routes.find(route => route.path === routeObj.path && route.verb === routeObj.verb.toLowerCase())) {
routeObj.verb = routeObj.verb.toLowerCase();
routes.push(routeObj);
}
});
Expand Down
3 changes: 2 additions & 1 deletion lib/parsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ export const parseCustomRoutes = (sailsConfig: Sails.Config): Array<ParsedCustom
for (const routeAddress in routes) {
// Parse 1: Route Address
// see https://sailsjs.com/documentation/concepts/routes/custom-routes#?route-address
let [verb, path] = routeAddress.split(/\s+/)
let [verb = 'get', path] = routeAddress.split(/\s+/)
verb = verb.toLowerCase();
if (!path) {
path = verb
verb = 'all'
Expand Down

0 comments on commit 58f80c9

Please sign in to comment.