cookie-es 1.2.1 → 1.2.3

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/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  <!-- /automd -->
11
11
 
12
- 🍪 [`Cookie`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cookie) and [`Set-Cookie`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie) parser and serializer based on [cookie](https://github.com/jshttp/cookiee) and [set-cookie-parser](https://github.com/nfriedly/set-cookie-parser) with dual ESM/CJS exports and bundled types. 🎁
12
+ 🍪 [`Cookie`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cookie) and [`Set-Cookie`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie) parser and serializer based on [cookie](https://github.com/jshttp/cookie) and [set-cookie-parser](https://github.com/nfriedly/set-cookie-parser) with dual ESM/CJS exports and bundled types. 🎁
13
13
 
14
14
  ## Usage
15
15
 
package/dist/index.cjs CHANGED
@@ -1,10 +1,16 @@
1
1
  'use strict';
2
2
 
3
+ const NullObject = /* @__PURE__ */ (() => {
4
+ const C = function() {
5
+ };
6
+ C.prototype = /* @__PURE__ */ Object.create(null);
7
+ return C;
8
+ })();
3
9
  function parse(str, options) {
4
10
  if (typeof str !== "string") {
5
11
  throw new TypeError("argument str must be a string");
6
12
  }
7
- const obj = {};
13
+ const obj = new NullObject();
8
14
  const opt = options || {};
9
15
  const dec = opt.decode || decode;
10
16
  let index = 0;
@@ -21,6 +27,10 @@ function parse(str, options) {
21
27
  continue;
22
28
  }
23
29
  const key = str.slice(index, eqIdx).trim();
30
+ if (opt?.filter && !opt?.filter(key)) {
31
+ index = endIdx + 1;
32
+ continue;
33
+ }
24
34
  if (void 0 === obj[key]) {
25
35
  let val = str.slice(eqIdx + 1, endIdx).trim();
26
36
  if (val.codePointAt(0) === 34) {
package/dist/index.mjs CHANGED
@@ -1,8 +1,14 @@
1
+ const NullObject = /* @__PURE__ */ (() => {
2
+ const C = function() {
3
+ };
4
+ C.prototype = /* @__PURE__ */ Object.create(null);
5
+ return C;
6
+ })();
1
7
  function parse(str, options) {
2
8
  if (typeof str !== "string") {
3
9
  throw new TypeError("argument str must be a string");
4
10
  }
5
- const obj = {};
11
+ const obj = new NullObject();
6
12
  const opt = options || {};
7
13
  const dec = opt.decode || decode;
8
14
  let index = 0;
@@ -19,6 +25,10 @@ function parse(str, options) {
19
25
  continue;
20
26
  }
21
27
  const key = str.slice(index, eqIdx).trim();
28
+ if (opt?.filter && !opt?.filter(key)) {
29
+ index = endIdx + 1;
30
+ continue;
31
+ }
22
32
  if (void 0 === obj[key]) {
23
33
  let val = str.slice(eqIdx + 1, endIdx).trim();
24
34
  if (val.codePointAt(0) === 34) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cookie-es",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "repository": "unjs/cookie-es",
5
5
  "license": "MIT",
6
6
  "sideEffects": false,
@@ -28,7 +28,7 @@
28
28
  "dev": "vitest --coverage",
29
29
  "lint": "eslint --cache . && prettier -c src test",
30
30
  "lint:fix": "automd && eslint --cache . --fix && prettier -c src test -w",
31
- "release": "pnpm test && pnpm build && changelogen --release --push && npm publish",
31
+ "release": "pnpm test && pnpm build && changelogen --release --push && npm publish --tag 1x",
32
32
  "test": "pnpm lint && vitest run --coverage"
33
33
  },
34
34
  "devDependencies": {