Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 560b2d8

Browse filesBrowse files
committed
Don't use regex to trim whitespace
1 parent b1bdb92 commit 560b2d8
Copy full SHA for 560b2d8

File tree

Expand file treeCollapse file tree

2 files changed

+4
-4
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+4
-4
lines changed

‎index.js

Copy file name to clipboardExpand all lines: index.js
+3-3Lines 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

Copy file name to clipboardExpand all lines: package.json
+1-1Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.