This repository has been archived by the owner on Nov 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
36 additions
and
5 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
packages/api-explorer/__tests__/lib/content-type-is-json.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const contentTypeIsJson = require('../../src/lib/content-type-is-json'); | ||
|
||
describe('contentTypeIsJson', () => { | ||
it('should return true if application/json', () => { | ||
const contentType = 'application/json'; | ||
expect(contentTypeIsJson(contentType)).toBe(true); | ||
}); | ||
|
||
it('should return true if application/vnd.api+json', () => { | ||
const contentType = 'application/vnd.api+json'; | ||
expect(contentTypeIsJson(contentType)).toBe(true); | ||
}); | ||
|
||
it('should return false otherwise', () => { | ||
const contentType = 'text/html'; | ||
expect(contentTypeIsJson(contentType)).toBe(false); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
function contentTypeIsJson(contentType) { | ||
const jsonContentTypes = ['application/json', 'application/vnd.api+json']; | ||
return jsonContentTypes.some(ct => contentType.includes(ct)); | ||
} | ||
|
||
module.exports = contentTypeIsJson; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters