https://github.com/charmander/7239
Parses Forwarded headers according to RFC 7239.
https://github.com/charmander/7239
Last synced: 11 months ago
JSON representation
Parses Forwarded headers according to RFC 7239.
- Host: GitHub
- URL: https://github.com/charmander/7239
- Owner: charmander
- License: isc
- Created: 2015-09-14T06:22:22.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2018-12-02T05:04:12.000Z (over 7 years ago)
- Last Synced: 2025-03-30T08:33:01.128Z (over 1 year ago)
- Language: JavaScript
- Size: 16.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 7239
[![Build status][ci-image]][ci]
A module to parse Forwarded headers according to [RFC 7239][].
```javascript
const sttn = require('7239');
sttn.parseForwardedHeader('for=203.0.113.72;proto=https')
// [{ for: '203.0.113.72', proto: 'https', by: null, host: null }]
sttn.parseForwardedHeader('for=[2001:db8::39]')
// null
app.use(sttn.middleware);
```
The middleware is compatible with [Connect][] (and therefore Express).
It adds a `forwarded` property to the request, with the value of the last
forwarded element or `{ for: null, proto: null, by: null, host: null }`
if no such object exists or if the header is invalid.
[RFC 7239]: https://tools.ietf.org/html/rfc7239
[Connect]: https://github.com/senchalabs/connect
[ci]: https://travis-ci.org/charmander/7239
[ci-image]: https://api.travis-ci.org/charmander/7239.svg