https://github.com/foundy/express-resolve-path
Rewrite the path of the request url in the correct form.
https://github.com/foundy/express-resolve-path
express path pathname resolve
Last synced: 4 months ago
JSON representation
Rewrite the path of the request url in the correct form.
- Host: GitHub
- URL: https://github.com/foundy/express-resolve-path
- Owner: foundy
- License: mit
- Created: 2018-01-31T05:56:39.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-01T08:25:52.000Z (over 8 years ago)
- Last Synced: 2025-08-13T08:20:36.513Z (11 months ago)
- Topics: express, path, pathname, resolve
- Language: JavaScript
- Size: 4.88 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# express-resolve-path
[](https://travis-ci.org/foundy/express-resolve-path)
`Recommended Node.js version`: **>= 8.9.0 (LTS)**
Express middleware that rewrites paths with multiple slashes to the correct path.
For example, when a request comes in the path of multiple slashes, it is rewritten to the converted path as shown below to match the routing rule.
`Request path`: ///foo///bar//?val=hello
`Rewrite path`: /foo/bar?val=hello
# Install
`$ npm install express-resolve-path`
# API
```javascript
const resolvePath = require('express-resolve-path');
const app = express();
app.use(resolvePath());
app.get('/foo', (req, res) => res.send('Hello'));
```
## resolvePath([options])
### Options
#### methods
Specifies the requested method to apply. (not case-sensitive)
```javascript
// methods specifying a single method
app.use(resolvePath({ methods: 'GET' }));
// methods specify multiple methods
app.use(resolvePath({ methods: 'GET POST' }));
// methods
app.use(resolvePath({ methods: ['GET', 'POST'] }));
```
# License
[MIT](https://github.com/foundy/express-resolve-path/blob/master/LICENSE)