Skip to content

Commit

Permalink
Remove code 306
Browse files Browse the repository at this point in the history
closes #18
closes #19
  • Loading branch information
jonchurch authored and dougwilson committed Apr 17, 2020
1 parent 055ea4d commit eab4c63
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 5 deletions.
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

0 comments on commit eab4c63

Please sign in to comment.