Skip to content

Commit 2bcb175

Browse files
committed
one or the other works
1 parent 55e8a81 commit 2bcb175

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/audits/server.ts

+16-4
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export function serverAudits(opts: ServerAuditOptions): Audit[] {
7575
),
7676
audit(
7777
'47DE',
78-
'SHOULD accept */* and use application/json for the content-type',
78+
'SHOULD accept */* and use application/graphql-response+json or application/json for the content-type',
7979
async () => {
8080
const res = await fetchFn(await getUrl(opts.url), {
8181
method: 'POST',
@@ -86,12 +86,18 @@ export function serverAudits(opts: ServerAuditOptions): Audit[] {
8686
body: JSON.stringify({ query: '{ __typename }' }),
8787
});
8888
ressert(res).status.toBe(200);
89-
ressert(res).header('content-type').toContain('application/json');
89+
try {
90+
ressert(res)
91+
.header('content-type')
92+
.toContain('application/graphql-response+json');
93+
} catch {
94+
ressert(res).header('content-type').toContain('application/json');
95+
}
9096
},
9197
),
9298
audit(
9399
'80D8',
94-
'SHOULD assume application/json content-type when accept is missing',
100+
'SHOULD assume application/json or application/graphql-response+json content-type when accept is missing',
95101
async () => {
96102
const res = await fetchFn(await getUrl(opts.url), {
97103
method: 'POST',
@@ -102,7 +108,13 @@ export function serverAudits(opts: ServerAuditOptions): Audit[] {
102108
});
103109

104110
ressert(res).status.toBe(200);
105-
ressert(res).header('content-type').toContain('application/json');
111+
try {
112+
ressert(res)
113+
.header('content-type')
114+
.toContain('application/graphql-response+json');
115+
} catch {
116+
ressert(res).header('content-type').toContain('application/json');
117+
}
106118
},
107119
),
108120
audit('82A3', 'MUST use utf-8 encoding when responding', async () => {

0 commit comments

Comments
 (0)