@tinyhttp/cookie
Advanced tools
Comparing version 0.0.11 to 0.0.12
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=/; */,t=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function i(e,t=decodeURIComponent){try{return t(e)}catch(t){return e}}exports.parse=function(t,r={decode:decodeURIComponent}){const n={},o=t.split(e);for(const e of o){let t=e.indexOf("=");if(t<0)continue;const o=e.substr(0,t).trim();let s=e.substr(++t,e.length).trim();'"'==s[0]&&(s=s.slice(1,-1)),null==n[o]&&(n[o]=i(s,r.decode))}return n},exports.serialize=function(e,i,{encode:r=encodeURIComponent,domain:n,secure:o,httpOnly:s,expires:a,path:c,...p}){if(!t.test(e))throw new TypeError("argument name is invalid");const f=r(i);if(f&&!t.test(f))throw new TypeError("argument val is invalid");let l=e+"="+f;if(null!=p.maxAge){const e=p.maxAge-0;if(isNaN(e)||!isFinite(e))throw new TypeError("option maxAge is invalid");l+="; Max-Age="+Math.floor(e)}if(n){if(!t.test(n))throw new TypeError("option domain is invalid");l+="; Domain="+n}if(c){if(!t.test(c))throw new TypeError("option path is invalid");l+="; Path="+c}if(a){if("function"!=typeof a.toUTCString)throw new TypeError("option expires is invalid");l+="; Expires="+a.toUTCString()}if(s&&(l+="; HttpOnly"),o&&(l+="; Secure"),p.sameSite){switch("string"==typeof p.sameSite?p.sameSite.toLowerCase():p.sameSite){case!0:l+="; SameSite=Strict";break;case"lax":l+="; SameSite=Lax";break;case"strict":l+="; SameSite=Strict";break;case"none":l+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return l}; | ||
const e=/; */,t=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function i(e,t=decodeURIComponent){try{return t(e)}catch(t){return e}}function n(t,n={decode:decodeURIComponent}){const o={},r=t.split(e);for(const e of r){let t=e.indexOf("=");if(t<0)continue;const r=e.substr(0,t).trim();let a=e.substr(++t,e.length).trim();'"'==a[0]&&(a=a.slice(1,-1)),null==o[r]&&(o[r]=i(a,n.decode))}return o}function o(e,i,{encode:n=encodeURIComponent,domain:o,secure:r,httpOnly:a,expires:s,path:c,...p}){if(!t.test(e))throw new TypeError("argument name is invalid");const f=n(i);if(f&&!t.test(f))throw new TypeError("argument val is invalid");let l=e+"="+f;if(null!=p.maxAge){const e=p.maxAge-0;if(isNaN(e)||!isFinite(e))throw new TypeError("option maxAge is invalid");l+="; Max-Age="+Math.floor(e)}if(o){if(!t.test(o))throw new TypeError("option domain is invalid");l+="; Domain="+o}if(c){if(!t.test(c))throw new TypeError("option path is invalid");l+="; Path="+c}if(s){if("function"!=typeof s.toUTCString)throw new TypeError("option expires is invalid");l+="; Expires="+s.toUTCString()}if(a&&(l+="; HttpOnly"),r&&(l+="; Secure"),p.sameSite){switch("string"==typeof p.sameSite?p.sameSite.toLowerCase():p.sameSite){case!0:l+="; SameSite=Strict";break;case"lax":l+="; SameSite=Lax";break;case"strict":l+="; SameSite=Strict";break;case"none":l+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return l}export{n as parse,o as serialize}; |
{ | ||
"name": "@tinyhttp/cookie", | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"description": "HTTP cookie parser and serializer for Node.js", | ||
@@ -17,5 +17,13 @@ "homepage": "https://github.com/talentlessguy/tinyhttp", | ||
}, | ||
"main": "dist/index.js", | ||
"main": "dist/index.cjs.js", | ||
"types": "dist/index.d.ts", | ||
"module": "dist/index.esm.js", | ||
"module": "dist/index.js", | ||
"exports": { | ||
".": { | ||
"import": "./dist/index.js", | ||
"require": "./dist/index.cjs.js" | ||
}, | ||
"./package.json": "./package.json", | ||
"./": "./" | ||
}, | ||
"keywords": [ | ||
@@ -22,0 +30,0 @@ "tinyhttp", |
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
15259