Skip to content

Commit

Permalink
Merge branch 'master' into rfc7807
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmad Nassri authored Jul 17, 2020
2 parents 749c486 + 41e9540 commit aba4784
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ require('./polyfill')

module.exports = class Problem extends Error {
constructor () {
let args = Array.from(arguments)
let status = args.shift()
const args = Array.from(arguments)
const status = args.shift()

let base = Problem.BASE_URI || BASE_URI
let members
Expand Down Expand Up @@ -42,7 +42,7 @@ module.exports = class Problem extends Error {
throw new Error(ERR_STATUS)
}

let statusNumber = Number(status)
const statusNumber = Number(status)

if ((statusNumber >= 600 || statusNumber < 400) && statusNumber !== 207) {
throw new Error(ERR_STATUS)
Expand Down
6 changes: 3 additions & 3 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ tap.test('API Problem', assert => {
assert.equal(new Problem(402).title, STATUS_CODES[402], '"title" SHOULD be the same as the recommended HTTP status phrase for "status"')
assert.equal(new Problem(402).type, STATUS_CODES_WEB + 402, '"type" should use STATUS_CODES_WEB when using standard "STATUS_CODES" and no "type" provided')

assert.equal(new Problem(444, 'foo').type, STATUS_CODES_WEB + 444, `default "type" should be an IANA_STATUS_CODE link`)
assert.equal(new Problem(444, 'foo').type, STATUS_CODES_WEB + 444, 'default "type" should be an IANA_STATUS_CODE link')

Problem.BASE_URI = 'foo://bar/'

Expand Down Expand Up @@ -66,9 +66,9 @@ tap.test('Object conversion', assert => {
tap.test('HTTP Response', assert => {
assert.plan(3)

let problem = new Problem(404)
const problem = new Problem(404)

let response = {
const response = {
writeHead: (status, headers) => {
assert.equal(status, '404', 'set correct status code')
assert.equal(headers['Content-Type'], CONTENT_TYPE, 'set correct Content-Type')
Expand Down
4 changes: 2 additions & 2 deletions test/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ const CONTENT_TYPE = 'application/problem+json'
tap.test('Express Middleware', assert => {
assert.plan(5)

let problem = new Problem(404)
const problem = new Problem(404)

let req = {}
const req = {}
let res = {
writeHead (status, headers) {
assert.equal(status, '404', 'set correct status code')
Expand Down

0 comments on commit aba4784

Please sign in to comment.