router-http 2.0.4 → 2.0.6

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.
Files changed (2) hide show
  1. package/package.json +1 -3
  2. package/src/index.js +8 -2
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "router-http",
3
3
  "description": "Simple HTTP router compatible with Express",
4
4
  "homepage": "https://github.com/Kikobeats/router-http",
5
- "version": "2.0.4",
5
+ "version": "2.0.6",
6
6
  "main": "src/index.js",
7
7
  "author": {
8
8
  "email": "josefrancisco.verdu@gmail.com",
@@ -35,7 +35,6 @@
35
35
  "devDependencies": {
36
36
  "@commitlint/cli": "latest",
37
37
  "@commitlint/config-conventional": "latest",
38
- "@ksmithut/prettier-standard": "latest",
39
38
  "async-listen": "latest",
40
39
  "ava": "latest",
41
40
  "c8": "latest",
@@ -81,7 +80,6 @@
81
80
  },
82
81
  "nano-staged": {
83
82
  "*.js": [
84
- "prettier-standard",
85
83
  "standard --fix"
86
84
  ],
87
85
  "package.json": [
package/src/index.js CHANGED
@@ -45,9 +45,15 @@ const parseUrl = ({ url }) => {
45
45
  }
46
46
  }
47
47
 
48
+ const QUESTION_MARK_CHAR_CODE = 63
49
+
48
50
  const mutateRequestUrl = (prefix, req) => {
49
- req.url = req.url.substring(prefix.length) || '/'
50
- req.path = req.path.substring(prefix.length) || '/'
51
+ const remainingUrl = req.url.substring(prefix.length)
52
+ req.url = !remainingUrl || remainingUrl.charCodeAt(0) === QUESTION_MARK_CHAR_CODE
53
+ ? `/${remainingUrl}`
54
+ : remainingUrl
55
+ const remainingPath = req.path.substring(prefix.length)
56
+ req.path = remainingPath || '/'
51
57
  }
52
58
 
53
59
  module.exports = (finalhandler = requiredFinalHandler(), options = {}) => {