0http-bun 1.0.2 → 1.0.3
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/lib/router/sequential.js +7 -3
- package/package.json +3 -2
package/lib/router/sequential.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const Trouter = require('trouter')
|
|
2
|
+
const qs = require('fast-querystring')
|
|
2
3
|
const next = require('./../next')
|
|
3
4
|
|
|
4
5
|
const status404 = {
|
|
@@ -36,10 +37,13 @@ module.exports = (config = {}) => {
|
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
router.fetch = (req) => {
|
|
39
|
-
const url =
|
|
40
|
+
const url = req.url
|
|
41
|
+
const startIndex = url.indexOf('/', 11)
|
|
42
|
+
const queryIndex = url.indexOf('?', startIndex + 1)
|
|
43
|
+
const path = queryIndex === -1 ? url.substring(startIndex) : url.substring(startIndex, queryIndex)
|
|
40
44
|
|
|
41
|
-
req.path =
|
|
42
|
-
req.query = url.
|
|
45
|
+
req.path = path || '/'
|
|
46
|
+
req.query = queryIndex > 0 ? qs.parse(url.substring(queryIndex + 1)) : {}
|
|
43
47
|
|
|
44
48
|
const match = router.find(req.method, req.path)
|
|
45
49
|
if (match.handlers.length > 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "0http-bun",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "0http for Bun",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"format": "bun x standard --fix"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
+
"fast-querystring": "^1.1.2",
|
|
11
12
|
"trouter": "^3.2.1"
|
|
12
13
|
},
|
|
13
14
|
"repository": {
|
|
@@ -21,7 +22,7 @@
|
|
|
21
22
|
"lib/"
|
|
22
23
|
],
|
|
23
24
|
"devDependencies": {
|
|
24
|
-
"0http-bun": "^1.0.
|
|
25
|
+
"0http-bun": "^1.0.2",
|
|
25
26
|
"mitata": "^0.1.11"
|
|
26
27
|
},
|
|
27
28
|
"keywords": [
|