We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5a1bb1b commit 844776fCopy full SHA for 844776f
src/operations/add.ts
@@ -11,6 +11,11 @@ export function addRoute<T>(
11
path: string,
12
data?: T,
13
): void {
14
+ method = method.toUpperCase();
15
+ if (path[0] !== "/") {
16
+ path = `/${path}`;
17
+ }
18
+
19
const segments = splitPath(path);
20
21
let node = ctx.root;
@@ -72,10 +77,8 @@ export function addRoute<T>(
72
77
if (!node.methods) {
73
78
node.methods = new NullProtoObj();
74
79
}
75
- if (!node.methods![method]) {
76
- node.methods![method] = [];
- }
- node.methods![method].push({
80
+ node.methods![method] ??= [];
81
+ node.methods![method]!.push({
82
data: data || (null as T),
83
paramsMap: hasParams ? paramsMap : undefined,
84
});
0 commit comments