binhend 1.1.6 → 1.1.7
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/package.json +1 -1
- package/src/server.js +12 -0
package/package.json
CHANGED
package/src/server.js
CHANGED
|
@@ -8,6 +8,18 @@ function Server(options) {
|
|
|
8
8
|
const WEB_DIRECTORY = options.web;
|
|
9
9
|
const CORS = options.cors;
|
|
10
10
|
|
|
11
|
+
// Handle error of ExpressJS: URIError: Failed to decode param
|
|
12
|
+
// Error happens when add wrong '%' (e.i. invalid encoded URI component) into the request URL
|
|
13
|
+
server.use(function(req, res, next) {
|
|
14
|
+
try {
|
|
15
|
+
decodeURIComponent(req.path);
|
|
16
|
+
next();
|
|
17
|
+
}
|
|
18
|
+
catch(e) {
|
|
19
|
+
res.redirect('/');
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
11
23
|
if (CORS instanceof Function) {
|
|
12
24
|
server.use(CORS);
|
|
13
25
|
}
|