|
1 | 1 | import isPlainObj from 'is-plain-obj' |
2 | | -import statuses from 'statuses' |
3 | 2 |
|
4 | 3 | // Normalize and validate options |
5 | 4 | export const getOptions = function (options = {}) { |
@@ -34,12 +33,21 @@ const validateStatus = function (optValue, optName) { |
34 | 33 | throw new TypeError(`"${optName}" must be an integer: ${optValue}`) |
35 | 34 | } |
36 | 35 |
|
37 | | - if (!STATUSES.has(optValue)) { |
| 36 | + if (!HTTP_STATUSES.has(optValue)) { |
38 | 37 | throw new TypeError(`"${optName}" must be an HTTP status code: ${optValue}`) |
39 | 38 | } |
40 | 39 | } |
41 | 40 |
|
42 | | -const STATUSES = new Set(statuses.codes) |
| 41 | +// TODO: replace with `statuses` package once they become a pure ES module |
| 42 | +/* eslint-disable no-magic-numbers */ |
| 43 | +const HTTP_STATUSES = new Set([ |
| 44 | + 100, 101, 102, 103, 200, 201, 202, 203, 204, 205, 206, 207, 208, 226, 300, |
| 45 | + 301, 302, 303, 304, 305, 307, 308, 400, 401, 402, 403, 404, 405, 406, 407, |
| 46 | + 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 421, 422, 423, 424, |
| 47 | + 425, 426, 428, 429, 431, 451, 500, 501, 502, 503, 504, 505, 506, 507, 508, |
| 48 | + 509, 510, 511, |
| 49 | +]) |
| 50 | +/* eslint-enable no-magic-numbers */ |
43 | 51 |
|
44 | 52 | const validateURI = function (optValue, optName) { |
45 | 53 | validateString(optValue, optName) |
|
0 commit comments