Skip to content

Commit 560b2d8

Browse files
committed
Don't use regex to trim whitespace
1 parent b1bdb92 commit 560b2d8

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ function parseCacheControl(header) {
8080

8181
// 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),
8282
// the directive's value is considered invalid. Caches are encouraged to consider responses that have invalid freshness information to be stale
83-
const parts = header.trim().split(/\s*,\s*/); // TODO: lame parsing
83+
const parts = header.trim().split(/,/);
8484
for (const part of parts) {
85-
const [k, v] = part.split(/\s*=\s*/, 2);
86-
cc[k] = v === undefined ? true : v.replace(/^"|"$/g, ''); // TODO: lame unquoting
85+
const [k, v] = part.split(/=/, 2);
86+
cc[k.trim()] = v === undefined ? true : v.trim().replace(/^"|"$/g, '');
8787
}
8888

8989
return cc;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "http-cache-semantics",
3-
"version": "4.1.0",
3+
"version": "4.1.1",
44
"description": "Parses Cache-Control and other headers. Helps building correct HTTP caches and proxies",
55
"repository": "https://github.com/kornelski/http-cache-semantics.git",
66
"main": "index.js",

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy