Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw on code 306 #19

Merged
merged 1 commit into from
Apr 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ unreleased

* Drop support for Node.js 0.6
* Fix messaging casing of `418 I'm a Teapot`
* Remove code 306
* Remove `status[code]` exports; use `status.message[code]`
* Remove `status[msg]` exports; use `status.code[msg]`
* Rename `425 Unordered Collection` to standard `425 Too Early`
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ status(403) // => 'Forbibben'
status('403') // => 'Forbibben'
status('forbidden') // => 403
status('Forbidden') // => 403
status(306) // throws, as it's not supported by node.js
status(306) // throws, as it's no longer supported by the HTTP spec
```

### status.codes
Expand Down
1 change: 0 additions & 1 deletion codes.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"303": "See Other",
"304": "Not Modified",
"305": "Use Proxy",
"306": "(Unused)",
"307": "Temporary Redirect",
"308": "Permanent Redirect",
"400": "Bad Request",
Expand Down
12 changes: 10 additions & 2 deletions scripts/fetch-iana.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,17 @@ https.get(URL, { headers: HEADERS }, function onResponse (res) {
rows.forEach(function (row) {
var obj = row.reduce(reduceRows, {})

if (obj.description !== 'Unassigned') {
codes[obj.value] = obj.description
// skip unassigned codes
if (obj.description === 'Unassigned') {
return
}

// skip retired 306 code
if (obj.value === '306') {
return
}

codes[obj.value] = obj.description
})

write(path.join(__dirname, '../src/iana.json'), codes)
Expand Down
1 change: 0 additions & 1 deletion src/iana.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"303": "See Other",
"304": "Not Modified",
"305": "Use Proxy",
"306": "(Unused)",
"307": "Temporary Redirect",
"308": "Permanent Redirect",
"400": "Bad Request",
Expand Down
4 changes: 4 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ describe('status', function () {
assert.throws(status.bind(null, 299), /invalid status code/)
assert.throws(status.bind(null, 310), /invalid status code/)
})

it('should throw for discontinued status code', function () {
assert.throws(status.bind(null, 306), /invalid status code/)
})
})

describe('when given a string', function () {
Expand Down