From 560b2d8ef452bbba20ffed69dc155d63ac757b74 Mon Sep 17 00:00:00 2001 From: Kornel Date: Fri, 27 Jan 2023 01:20:38 +0000 Subject: [PATCH] Don't use regex to trim whitespace --- index.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 050016a..31fba48 100644 --- a/index.js +++ b/index.js @@ -80,10 +80,10 @@ function parseCacheControl(header) { // TODO: When there is more than one value present for a given directive (e.g., two Expires header fields, multiple Cache-Control: max-age directives), // the directive's value is considered invalid. Caches are encouraged to consider responses that have invalid freshness information to be stale - const parts = header.trim().split(/\s*,\s*/); // TODO: lame parsing + const parts = header.trim().split(/,/); for (const part of parts) { - const [k, v] = part.split(/\s*=\s*/, 2); - cc[k] = v === undefined ? true : v.replace(/^"|"$/g, ''); // TODO: lame unquoting + const [k, v] = part.split(/=/, 2); + cc[k.trim()] = v === undefined ? true : v.trim().replace(/^"|"$/g, ''); } return cc; diff --git a/package.json b/package.json index 5920c33..d3b590e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "http-cache-semantics", - "version": "4.1.0", + "version": "4.1.1", "description": "Parses Cache-Control and other headers. Helps building correct HTTP caches and proxies", "repository": "https://github.com/kornelski/http-cache-semantics.git", "main": "index.js",