header-field
Advanced tools
Comparing version 0.1.0 to 0.1.1
12
index.js
@@ -9,7 +9,13 @@ var hyphenReg = /-[a-z]/g; | ||
if (!str) return ""; | ||
str = String(str).toLowerCase(); | ||
return ( | ||
var result = String(str); | ||
result = ( | ||
toUpperCase(str[0]) + | ||
str.slice(1).replace(hyphenReg, toUpperCase) | ||
str | ||
.slice(1) | ||
.toLowerCase() | ||
.replace(hyphenReg, toUpperCase) | ||
); | ||
// Special case to fix the broken http spec. | ||
if (result === "Referrer") result = "Referer"; | ||
return result; | ||
} | ||
@@ -16,0 +22,0 @@ |
{ | ||
"name": "header-field", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Properly format a header field into a capitalized hyphenated string.", | ||
@@ -5,0 +5,0 @@ "author": "Dylan Piercey <pierceydylan@gmail.com>", |
@@ -19,2 +19,5 @@ # Header-Field | ||
field("Content-Disposition"); //-> "Content-Disposition" | ||
// Special case: referrer -> referer. | ||
field("referrer"); //-> "Referer" | ||
``` | ||
@@ -21,0 +24,0 @@ |
@@ -10,3 +10,4 @@ var assert = require("assert"); | ||
assert.equal(field("Content-DisPosition"), "Content-Disposition"); | ||
assert.equal(field("referrer"), "Referer"); | ||
}); | ||
}); |
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
2451
44
29