spooder 4.6.1 → 4.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bun.lock +4 -4
- package/package.json +5 -5
- package/src/api.ts +6 -1
package/bun.lock
CHANGED
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
},
|
|
13
13
|
},
|
|
14
14
|
"packages": {
|
|
15
|
-
"@types/bun": ["@types/bun@1.2.
|
|
15
|
+
"@types/bun": ["@types/bun@1.2.16", "", { "dependencies": { "bun-types": "1.2.16" } }, "sha512-1aCZJ/6nSiViw339RsaNhkNoEloLaPzZhxMOYEa7OzRzO41IGg5n/7I43/ZIAW/c+Q6cT12Vf7fOZOoVIzb5BQ=="],
|
|
16
16
|
|
|
17
|
-
"@types/node": ["@types/node@
|
|
17
|
+
"@types/node": ["@types/node@24.0.1", "", { "dependencies": { "undici-types": "~7.8.0" } }, "sha512-MX4Zioh39chHlDJbKmEgydJDS3tspMP/lnQC67G3SWsTnb9NeYVWOjkxpOSy4oMfPs4StcWHwBrvUb4ybfnuaw=="],
|
|
18
18
|
|
|
19
19
|
"aws-ssl-profiles": ["aws-ssl-profiles@1.1.2", "", {}, "sha512-NZKeq9AfyQvEeNlN0zSYAaWrmBffJh3IELMZfRpJVWgrpEbtEpnjvzqBPf+mxoI287JohRDoa+/nsfqqiZmF6g=="],
|
|
20
20
|
|
|
21
|
-
"bun-types": ["bun-types@1.2.
|
|
21
|
+
"bun-types": ["bun-types@1.2.16", "", { "dependencies": { "@types/node": "*" } }, "sha512-ciXLrHV4PXax9vHvUrkvun9VPVGOVwbbbBF/Ev1cXz12lyEZMoJpIJABOfPcN9gDJRaiKF9MVbSygLg4NXu3/A=="],
|
|
22
22
|
|
|
23
23
|
"denque": ["denque@2.1.0", "", {}, "sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw=="],
|
|
24
24
|
|
|
@@ -44,6 +44,6 @@
|
|
|
44
44
|
|
|
45
45
|
"sqlstring": ["sqlstring@2.3.3", "", {}, "sha512-qC9iz2FlN7DQl3+wjwn3802RTyjCx7sDvfQEXchwa6CWOx07/WVfh91gBmQ9fahw8snwGEWU3xGzOt4tFyHLxg=="],
|
|
46
46
|
|
|
47
|
-
"undici-types": ["undici-types@
|
|
47
|
+
"undici-types": ["undici-types@7.8.0", "", {}, "sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw=="],
|
|
48
48
|
}
|
|
49
49
|
}
|
package/package.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spooder",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.6.
|
|
4
|
+
"version": "4.6.2",
|
|
5
|
+
"module": "./src/api.ts",
|
|
6
|
+
"bin": {
|
|
7
|
+
"spooder": "./src/cli.ts"
|
|
8
|
+
},
|
|
5
9
|
"exports": {
|
|
6
10
|
".": {
|
|
7
11
|
"bun": "./src/api.ts",
|
|
8
12
|
"import": "./src/api.ts"
|
|
9
13
|
}
|
|
10
14
|
},
|
|
11
|
-
"module": "./src/api.ts",
|
|
12
15
|
"devDependencies": {
|
|
13
16
|
"@types/bun": "^1.1.8"
|
|
14
17
|
},
|
|
15
18
|
"optionalDependencies": {
|
|
16
19
|
"mysql2": "^3.11.0"
|
|
17
|
-
},
|
|
18
|
-
"bin": {
|
|
19
|
-
"spooder": "./src/cli.ts"
|
|
20
20
|
}
|
|
21
21
|
}
|
package/src/api.ts
CHANGED
|
@@ -725,7 +725,10 @@ export function serve(port: number, hostname?: string) {
|
|
|
725
725
|
let status_code = 200;
|
|
726
726
|
|
|
727
727
|
try {
|
|
728
|
-
|
|
728
|
+
let pathname = url.pathname;
|
|
729
|
+
if (pathname.length > 1 && pathname.endsWith('/'))
|
|
730
|
+
pathname = pathname.slice(0, -1);
|
|
731
|
+
const route_array = pathname.split('/').filter(e => !(e === '..' || e === '.'));
|
|
729
732
|
let handler: RequestHandler | undefined;
|
|
730
733
|
let methods: HTTP_METHODS | undefined;
|
|
731
734
|
|
|
@@ -873,6 +876,8 @@ export function serve(port: number, hostname?: string) {
|
|
|
873
876
|
return {
|
|
874
877
|
/** Register a handler for a specific route. */
|
|
875
878
|
route: (path: string, handler: RequestHandler, method: HTTP_METHODS = 'GET'): void => {
|
|
879
|
+
if (path.length > 1 && path.endsWith('/'))
|
|
880
|
+
path = path.slice(0, -1);
|
|
876
881
|
routes.push([path.split('/'), handler, method]);
|
|
877
882
|
},
|
|
878
883
|
|