Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ module.exports = class Router extends EventEmitter {

for(let method of methods) {
this[method] = (path, ...callbacks) => {
return this.createRoute(method.toUpperCase(), path, this, ...callbacks);
return this.createRoute(method, path, this, ...callbacks);
};
};
}
Expand Down Expand Up @@ -132,6 +132,7 @@ module.exports = class Router extends EventEmitter {
}

createRoute(method, path, parent = this, ...callbacks) {
method = method.toUpperCase();
callbacks = callbacks.flat();
const paths = Array.isArray(path) ? path : [path];
const routes = [];
Expand All @@ -143,7 +144,7 @@ module.exports = class Router extends EventEmitter {
path = '/*';
}
const route = {
method: method === 'USE' ? 'ALL' : method.toUpperCase(),
method: method === 'USE' ? 'ALL' : method,
path,
pattern: method === 'USE' || needsConversionToRegex(path) ? patternToRegex(path, method === 'USE') : path,
callbacks,
Expand Down Expand Up @@ -627,7 +628,7 @@ module.exports = class Router extends EventEmitter {
let fns = new NullObject();
for(let method of methods) {
fns[method] = (...callbacks) => {
return this.createRoute(method.toUpperCase(), path, fns, ...callbacks);
return this.createRoute(method, path, fns, ...callbacks);
};
}
fns.get = (...callbacks) => {
Expand Down