set-cookie-parser
Advanced tools
Comparing version 2.4.7 to 2.4.8
@@ -27,3 +27,5 @@ "use strict"; | ||
console.error( | ||
`set-cookie-parser encountered an error while decoding a cookie with value '${value}'. Set options.decodeValues to false to disable this feature.`, | ||
"set-cookie-parser encountered an error while decoding a cookie with value '" + | ||
value + | ||
"'. Set options.decodeValues to false to disable this feature.", | ||
e | ||
@@ -30,0 +32,0 @@ ); |
{ | ||
"name": "set-cookie-parser", | ||
"version": "2.4.7", | ||
"version": "2.4.8", | ||
"description": "Parses set-cookie headers into objects", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/nfriedly/set-cookie-parser", |
@@ -119,2 +119,26 @@ # set-cookie-parser | ||
### Creating a new, modified set-cookie header | ||
This library can be used in conjunction with the [cookie](https://www.npmjs.com/package/cookie) library to modify and replace set-cookie headers: | ||
```js | ||
const libCookie = require('cookie'); | ||
const setCookie = require('set-cookie-parser'); | ||
function modifySetCookie(res){ | ||
// parse the set-cookie headers with this library | ||
let cookies = setCookie.parse(res); | ||
// modify the cookies here | ||
// ... | ||
// create new set-cookie headers using the cookie library | ||
res.headers['set-cookie'] = cookies.map(function(cookie) { | ||
return libCookie.serialize(cookie.name, cookie.value, cookie); | ||
}); | ||
} | ||
``` | ||
See a real-world example of this in [unblocker](https://github.com/nfriedly/node-unblocker/blob/a894c0861af26489d2467c94fbc500770f57464f/lib/cookies.js#L62-L76) | ||
## Usage in React Native | ||
@@ -121,0 +145,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14655
174
201