Skip to content

Commit

Permalink
fix(type): update type web url (#249)
Browse files Browse the repository at this point in the history
Update the type web base url to MDN.

BREAKING CHANGE: The type default domain is now MDN. This will most likely break tests.
  • Loading branch information
billxinli authored Nov 27, 2022
1 parent e89be44 commit 7533280
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ import Problem from 'api-problem'

// HTTP defaults
new Problem(404)
//=> { status: '404', title: 'Not Found', type: 'https://httpstatuses.com/404' }
//=> { status: '404', title: 'Not Found', type: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404' }

// override defaults
new Problem(404, 'Oops! Page Not Found')
//=> { status: '404', title: 'Oops! Page Not Found', type: 'https://httpstatuses.com/404' }
//=> { status: '404', title: 'Oops! Page Not Found', type: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404' }

// custom values
new Problem(403, 'You do not have enough credit', 'https://example.com/probs/out-of-credit')
Expand All @@ -60,7 +60,7 @@ new Problem(403, {
account_id: '12345'
})

//=> { status: '403', title: 'Forbidden', type: 'https://httpstatuses.com/404', detail: 'Account suspended', instance: '/account/12345', account_id: 12345, 'date: 2016-01-15T06:47:01.175Z' }
//=> { status: '403', title: 'Forbidden', type: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403', detail: 'Account suspended', instance: '/account/12345', account_id: 12345, 'date: 2016-01-15T06:47:01.175Z' }
```

### Method : `<object>` `toObject()`
Expand Down
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const CONTENT_TYPE = 'application/problem+json'
const DEFAULT_TYPE = 'about:blank'
const ERR_STATUS = '"status" must be a valid HTTP Error Status Code ([RFC7231], Section 6)'
const ERR_TITLE = 'missing "title". a short, human-readable summary of the problem type'
const STATUS_CODES_WEB = 'https://httpstatuses.com/'
const STATUS_CODES_WEB = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/'

// polyfill
require('./polyfill')
Expand Down
4 changes: 2 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const CONTENT_TYPE = 'application/problem+json'
const DEFAULT_TYPE = 'about:blank'
const ERR_STATUS = '"status" must be a valid HTTP Error Status Code ([RFC7231], Section 6)'
const ERR_TITLE = 'missing "title". a short, human-readable summary of the problem type'
const STATUS_CODES_WEB = 'https://httpstatuses.com/'
const STATUS_CODES_WEB = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/'

tap.test('API Problem', assert => {
assert.plan(19)
Expand Down Expand Up @@ -60,7 +60,7 @@ tap.test('Object conversion', assert => {

const obj = problem.toObject()

assert.same(obj, { type: 'https://httpstatuses.com/400', title: 'title', status: 400, foo: 'bar' })
assert.same(obj, { type: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400', title: 'title', status: 400, foo: 'bar' })
})

tap.test('HTTP Response', assert => {
Expand Down

0 comments on commit 7533280

Please sign in to comment.