Skip to content

Commit 978f4c8

Browse files
authored
fix: casing now matches what comes in a Netlify function via event.headers (#181)
1 parent d946c42 commit 978f4c8

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { loadSourceImage as defaultLoadSourceImage } from './http'
88
import { decodeBase64Params, doPatternsMatchUrl, RemotePattern } from './utils'
99

1010
// WAF is Web Application Firewall
11-
const WAF_BYPASS_TOKEN_HEADER = 'X-Nf-Waf-Bypass-Token'
11+
const WAF_BYPASS_TOKEN_HEADER = 'x-nf-waf-bypass-token'
1212

1313
export interface IPXHandlerOptions extends Partial<IPXOptions> {
1414
/**

test/index.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ test('should add WAF headers to local images being transformed', async (t) => {
107107
cacheDir: '/tmp/ipx-cache',
108108
bypassDomainCheck: true
109109
}, (sourceImageOptions) => {
110-
t.assert(sourceImageOptions.requestHeaders && sourceImageOptions.requestHeaders['X-Nf-Waf-Bypass-Token'] === 'some token')
110+
t.assert(sourceImageOptions.requestHeaders && sourceImageOptions.requestHeaders['x-nf-waf-bypass-token'] === 'some token')
111111

112112
return Promise.resolve({ finalize: () => { } } as SourceImageResult)
113113
})
@@ -116,7 +116,7 @@ test('should add WAF headers to local images being transformed', async (t) => {
116116
{
117117
rawUrl: 'http://localhost:3000/some-path',
118118
path: '/_ipx/w_500/no-file.jpg',
119-
headers: { 'X-Nf-Waf-Bypass-Token': 'some token' },
119+
headers: { 'x-nf-waf-bypass-token': 'some token' },
120120
rawQuery: '',
121121
httpMethod: 'GET',
122122
queryStringParameters: {},
@@ -135,7 +135,7 @@ test('should not add WAF headers to remote images being transformed', async (t)
135135
cacheDir: '/tmp/ipx-cache',
136136
bypassDomainCheck: true
137137
}, (sourceImageOptions) => {
138-
t.assert(sourceImageOptions.requestHeaders && sourceImageOptions.requestHeaders['X-Nf-Waf-Bypass-Token'] === undefined)
138+
t.assert(sourceImageOptions.requestHeaders && sourceImageOptions.requestHeaders['x-nf-waf-bypass-token'] === undefined)
139139

140140
return Promise.resolve({ finalize: () => { } } as SourceImageResult)
141141
})
@@ -144,7 +144,7 @@ test('should not add WAF headers to remote images being transformed', async (t)
144144
{
145145
rawUrl: 'http://localhost:3000/some-path',
146146
path: '/_ipx/w_500/https%3A%2F%2Fsome-site.com%2Fno-file.jpg',
147-
headers: { 'X-Nf-Waf-Bypass-Token': 'some token' },
147+
headers: { 'x-nf-waf-bypass-token': 'some token' },
148148
rawQuery: '',
149149
httpMethod: 'GET',
150150
queryStringParameters: {},
@@ -162,7 +162,7 @@ test('should not add WAF headers to local images if WAF is disabled', async (t)
162162
cacheDir: '/tmp/ipx-cache',
163163
bypassDomainCheck: true
164164
}, (sourceImageOptions) => {
165-
t.assert(sourceImageOptions.requestHeaders && sourceImageOptions.requestHeaders['X-Nf-Waf-Bypass-Token'] === undefined)
165+
t.assert(sourceImageOptions.requestHeaders && sourceImageOptions.requestHeaders['x-nf-waf-bypass-token'] === undefined)
166166

167167
return Promise.resolve({ finalize: () => { } } as SourceImageResult)
168168
})

0 commit comments

Comments
 (0)