@netlify/edge-bundler 14.1.0 → 14.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -142,3 +142,96 @@ describe('import map URL', () => {
|
|
|
142
142
|
expect(() => validateManifest(manifest)).toThrowErrorMatchingSnapshot();
|
|
143
143
|
});
|
|
144
144
|
});
|
|
145
|
+
describe('route headers', () => {
|
|
146
|
+
test('should accept valid headers with exists style', () => {
|
|
147
|
+
const manifest = getBaseManifest();
|
|
148
|
+
manifest.routes[0].headers = {
|
|
149
|
+
'x-custom-header': {
|
|
150
|
+
style: 'exists',
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
expect(() => validateManifest(manifest)).not.toThrowError();
|
|
154
|
+
});
|
|
155
|
+
test('should accept valid headers with missing style', () => {
|
|
156
|
+
const manifest = getBaseManifest();
|
|
157
|
+
manifest.routes[0].headers = {
|
|
158
|
+
'x-custom-header': {
|
|
159
|
+
style: 'missing',
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
expect(() => validateManifest(manifest)).not.toThrowError();
|
|
163
|
+
});
|
|
164
|
+
test('should accept valid headers with regex style and pattern', () => {
|
|
165
|
+
const manifest = getBaseManifest();
|
|
166
|
+
manifest.routes[0].headers = {
|
|
167
|
+
'x-custom-header': {
|
|
168
|
+
style: 'regex',
|
|
169
|
+
pattern: '^Bearer .+$',
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
expect(() => validateManifest(manifest)).not.toThrowError();
|
|
173
|
+
});
|
|
174
|
+
test('should throw on missing style property', () => {
|
|
175
|
+
const manifest = getBaseManifest();
|
|
176
|
+
manifest.routes[0].headers = {
|
|
177
|
+
'x-custom-header': {
|
|
178
|
+
pattern: '^Bearer .+$',
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
expect(() => validateManifest(manifest)).toThrowErrorMatchingSnapshot();
|
|
182
|
+
});
|
|
183
|
+
test('should throw on invalid style value', () => {
|
|
184
|
+
const manifest = getBaseManifest();
|
|
185
|
+
manifest.routes[0].headers = {
|
|
186
|
+
'x-custom-header': {
|
|
187
|
+
style: 'invalid',
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
expect(() => validateManifest(manifest)).toThrowErrorMatchingSnapshot();
|
|
191
|
+
});
|
|
192
|
+
test('should throw when style is regex but pattern is missing', () => {
|
|
193
|
+
const manifest = getBaseManifest();
|
|
194
|
+
manifest.routes[0].headers = {
|
|
195
|
+
'x-custom-header': {
|
|
196
|
+
style: 'regex',
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
expect(() => validateManifest(manifest)).toThrowErrorMatchingSnapshot();
|
|
200
|
+
});
|
|
201
|
+
test('should throw on invalid pattern format', () => {
|
|
202
|
+
const manifest = getBaseManifest();
|
|
203
|
+
manifest.routes[0].headers = {
|
|
204
|
+
'x-custom-header': {
|
|
205
|
+
style: 'regex',
|
|
206
|
+
pattern: '/^Bearer .+/',
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
expect(() => validateManifest(manifest)).toThrowErrorMatchingSnapshot();
|
|
210
|
+
});
|
|
211
|
+
test('should throw on additional property in headers', () => {
|
|
212
|
+
const manifest = getBaseManifest();
|
|
213
|
+
manifest.routes[0].headers = {
|
|
214
|
+
'x-custom-header': {
|
|
215
|
+
style: 'exists',
|
|
216
|
+
foo: 'bar',
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
expect(() => validateManifest(manifest)).toThrowErrorMatchingSnapshot();
|
|
220
|
+
});
|
|
221
|
+
test('should accept multiple headers with different styles', () => {
|
|
222
|
+
const manifest = getBaseManifest();
|
|
223
|
+
manifest.routes[0].headers = {
|
|
224
|
+
'x-exists-header': {
|
|
225
|
+
style: 'exists',
|
|
226
|
+
},
|
|
227
|
+
'x-missing-header': {
|
|
228
|
+
style: 'missing',
|
|
229
|
+
},
|
|
230
|
+
authorization: {
|
|
231
|
+
style: 'regex',
|
|
232
|
+
pattern: '^Bearer [a-zA-Z0-9]+$',
|
|
233
|
+
},
|
|
234
|
+
};
|
|
235
|
+
expect(() => validateManifest(manifest)).not.toThrowError();
|
|
236
|
+
});
|
|
237
|
+
});
|
|
@@ -57,6 +57,37 @@ declare const edgeManifestSchema: {
|
|
|
57
57
|
enum: string[];
|
|
58
58
|
};
|
|
59
59
|
};
|
|
60
|
+
headers: {
|
|
61
|
+
type: string;
|
|
62
|
+
patternProperties: {
|
|
63
|
+
'.*': {
|
|
64
|
+
type: string;
|
|
65
|
+
required: string[];
|
|
66
|
+
properties: {
|
|
67
|
+
pattern: {
|
|
68
|
+
type: string;
|
|
69
|
+
format: string;
|
|
70
|
+
};
|
|
71
|
+
style: {
|
|
72
|
+
type: string;
|
|
73
|
+
enum: string[];
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
additionalProperties: boolean;
|
|
77
|
+
if: {
|
|
78
|
+
properties: {
|
|
79
|
+
style: {
|
|
80
|
+
const: string;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
then: {
|
|
85
|
+
required: string[];
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
additionalProperties: boolean;
|
|
90
|
+
};
|
|
60
91
|
};
|
|
61
92
|
additionalProperties: boolean;
|
|
62
93
|
};
|
|
@@ -99,6 +130,37 @@ declare const edgeManifestSchema: {
|
|
|
99
130
|
enum: string[];
|
|
100
131
|
};
|
|
101
132
|
};
|
|
133
|
+
headers: {
|
|
134
|
+
type: string;
|
|
135
|
+
patternProperties: {
|
|
136
|
+
'.*': {
|
|
137
|
+
type: string;
|
|
138
|
+
required: string[];
|
|
139
|
+
properties: {
|
|
140
|
+
pattern: {
|
|
141
|
+
type: string;
|
|
142
|
+
format: string;
|
|
143
|
+
};
|
|
144
|
+
style: {
|
|
145
|
+
type: string;
|
|
146
|
+
enum: string[];
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
additionalProperties: boolean;
|
|
150
|
+
if: {
|
|
151
|
+
properties: {
|
|
152
|
+
style: {
|
|
153
|
+
const: string;
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
then: {
|
|
158
|
+
required: string[];
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
additionalProperties: boolean;
|
|
163
|
+
};
|
|
102
164
|
};
|
|
103
165
|
additionalProperties: boolean;
|
|
104
166
|
};
|
|
@@ -15,6 +15,35 @@ const excludedPatternsSchema = {
|
|
|
15
15
|
errorMessage: 'excluded_patterns must be an array of regex that starts with ^ and ends with $ (e.g. ^/blog/[d]{4}$)',
|
|
16
16
|
},
|
|
17
17
|
};
|
|
18
|
+
const headersSchema = {
|
|
19
|
+
type: 'object',
|
|
20
|
+
patternProperties: {
|
|
21
|
+
'.*': {
|
|
22
|
+
type: 'object',
|
|
23
|
+
required: ['style'],
|
|
24
|
+
properties: {
|
|
25
|
+
pattern: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
format: 'regexPattern',
|
|
28
|
+
},
|
|
29
|
+
style: {
|
|
30
|
+
type: 'string',
|
|
31
|
+
enum: ['exists', 'missing', 'regex'],
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
additionalProperties: false,
|
|
35
|
+
if: {
|
|
36
|
+
properties: {
|
|
37
|
+
style: { const: 'regex' },
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
then: {
|
|
41
|
+
required: ['pattern'],
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
additionalProperties: false,
|
|
46
|
+
};
|
|
18
47
|
const routesSchema = {
|
|
19
48
|
type: 'object',
|
|
20
49
|
required: ['function', 'pattern'],
|
|
@@ -33,6 +62,7 @@ const routesSchema = {
|
|
|
33
62
|
type: 'array',
|
|
34
63
|
items: { type: 'string', enum: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'] },
|
|
35
64
|
},
|
|
65
|
+
headers: headersSchema,
|
|
36
66
|
},
|
|
37
67
|
additionalProperties: false,
|
|
38
68
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/edge-bundler",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.2.0",
|
|
4
4
|
"description": "Intelligently prepare Netlify Edge Functions for deployment",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/node/index.js",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"urlpattern-polyfill": "8.0.2",
|
|
82
82
|
"uuid": "^11.0.0"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "9ba8975b7363b7003117aa0b224ad0d129c11ef4"
|
|
85
85
|
}
|