@netlify/edge-bundler 14.2.0 → 14.2.2
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.
- package/dist/node/config.test.js +3 -3
- package/dist/node/declaration.d.ts +2 -2
- package/dist/node/declaration.js +4 -2
- package/dist/node/manifest.test.js +13 -13
- package/dist/node/validation/manifest/index.test.js +17 -17
- package/dist/node/validation/manifest/schema.d.ts +4 -4
- package/dist/node/validation/manifest/schema.js +3 -3
- package/package.json +2 -2
package/dist/node/config.test.js
CHANGED
|
@@ -265,14 +265,14 @@ test('Loads function paths from the in-source `config` function', async () => {
|
|
|
265
265
|
path: '/user-func1',
|
|
266
266
|
headers: {
|
|
267
267
|
'x-must-be-there': {
|
|
268
|
-
|
|
268
|
+
matcher: 'exists',
|
|
269
269
|
},
|
|
270
270
|
'x-must-match': {
|
|
271
271
|
pattern: '^(foo|bar)$',
|
|
272
|
-
|
|
272
|
+
matcher: 'regex',
|
|
273
273
|
},
|
|
274
274
|
'x-must-not-be-there': {
|
|
275
|
-
|
|
275
|
+
matcher: 'missing',
|
|
276
276
|
},
|
|
277
277
|
},
|
|
278
278
|
});
|
|
@@ -2,9 +2,9 @@ import { FunctionConfig, HeadersConfig, HTTPMethod, Path } from './config.js';
|
|
|
2
2
|
import { FeatureFlags } from './feature_flags.js';
|
|
3
3
|
export type HeaderMatch = {
|
|
4
4
|
pattern: string;
|
|
5
|
-
|
|
5
|
+
matcher: 'regex';
|
|
6
6
|
} | {
|
|
7
|
-
|
|
7
|
+
matcher: 'exists' | 'missing';
|
|
8
8
|
};
|
|
9
9
|
type HeaderMatchers = Record<string, HeaderMatch>;
|
|
10
10
|
interface BaseDeclaration {
|
package/dist/node/declaration.js
CHANGED
|
@@ -130,10 +130,12 @@ export const getHeaderMatchers = (headers) => {
|
|
|
130
130
|
}
|
|
131
131
|
for (const header in headers) {
|
|
132
132
|
if (typeof headers[header] === 'boolean') {
|
|
133
|
-
matchers[header] = {
|
|
133
|
+
matchers[header] = { matcher: headers[header] ? 'exists' : 'missing' };
|
|
134
134
|
}
|
|
135
135
|
else if (typeof headers[header] === 'string') {
|
|
136
|
-
|
|
136
|
+
// Strip leading and forward slashes.
|
|
137
|
+
const pattern = new RegExp(headers[header]).toString().slice(1, -1);
|
|
138
|
+
matchers[header] = { matcher: 'regex', pattern };
|
|
137
139
|
}
|
|
138
140
|
else {
|
|
139
141
|
throw new BundleError(new Error(headerConfigError));
|
|
@@ -215,11 +215,11 @@ test('excludedPath from ISC goes into function_config, TOML goes into routes', (
|
|
|
215
215
|
},
|
|
216
216
|
});
|
|
217
217
|
const matcher = getRouteMatcher(manifest);
|
|
218
|
-
expect(matcher('/showcases/boho-
|
|
218
|
+
expect(matcher('/showcases/boho-matcher')).toBeDefined();
|
|
219
219
|
expect(matcher('/checkout/address')).toBeDefined();
|
|
220
220
|
expect(matcher('/checkout/terms-and-conditions')).toBeUndefined();
|
|
221
221
|
expect(matcher('/checkout/scrooge-mc-duck-animation.css')).toBeUndefined();
|
|
222
|
-
expect(matcher('/showcases/boho-
|
|
222
|
+
expect(matcher('/showcases/boho-matcher/expensive-chair.jpg')).toBeUndefined();
|
|
223
223
|
});
|
|
224
224
|
test('URLPattern named groups are supported', () => {
|
|
225
225
|
const functions = [{ name: 'customisation', path: '/path/to/customisation.ts' }];
|
|
@@ -551,9 +551,9 @@ describe('Header matching', () => {
|
|
|
551
551
|
'x-present': true,
|
|
552
552
|
'x-also-present': true,
|
|
553
553
|
'x-absent': false,
|
|
554
|
-
'x-match-prefix': '^prefix
|
|
555
|
-
'x-match-exact': 'exact',
|
|
556
|
-
'x-match-suffix': '
|
|
554
|
+
'x-match-prefix': '^prefix',
|
|
555
|
+
'x-match-exact': '^exact$',
|
|
556
|
+
'x-match-suffix': 'suffix$',
|
|
557
557
|
},
|
|
558
558
|
},
|
|
559
559
|
];
|
|
@@ -570,25 +570,25 @@ describe('Header matching', () => {
|
|
|
570
570
|
path: '/f1/*',
|
|
571
571
|
headers: {
|
|
572
572
|
'x-absent': {
|
|
573
|
-
|
|
573
|
+
matcher: 'missing',
|
|
574
574
|
},
|
|
575
575
|
'x-also-present': {
|
|
576
|
-
|
|
576
|
+
matcher: 'exists',
|
|
577
577
|
},
|
|
578
578
|
'x-match-exact': {
|
|
579
579
|
pattern: '^exact$',
|
|
580
|
-
|
|
580
|
+
matcher: 'regex',
|
|
581
581
|
},
|
|
582
582
|
'x-match-prefix': {
|
|
583
|
-
pattern: '^prefix
|
|
584
|
-
|
|
583
|
+
pattern: '^prefix',
|
|
584
|
+
matcher: 'regex',
|
|
585
585
|
},
|
|
586
586
|
'x-match-suffix': {
|
|
587
|
-
pattern: '
|
|
588
|
-
|
|
587
|
+
pattern: 'suffix$',
|
|
588
|
+
matcher: 'regex',
|
|
589
589
|
},
|
|
590
590
|
'x-present': {
|
|
591
|
-
|
|
591
|
+
matcher: 'exists',
|
|
592
592
|
},
|
|
593
593
|
},
|
|
594
594
|
},
|
|
@@ -143,35 +143,35 @@ describe('import map URL', () => {
|
|
|
143
143
|
});
|
|
144
144
|
});
|
|
145
145
|
describe('route headers', () => {
|
|
146
|
-
test('should accept valid headers with exists
|
|
146
|
+
test('should accept valid headers with exists matcher', () => {
|
|
147
147
|
const manifest = getBaseManifest();
|
|
148
148
|
manifest.routes[0].headers = {
|
|
149
149
|
'x-custom-header': {
|
|
150
|
-
|
|
150
|
+
matcher: 'exists',
|
|
151
151
|
},
|
|
152
152
|
};
|
|
153
153
|
expect(() => validateManifest(manifest)).not.toThrowError();
|
|
154
154
|
});
|
|
155
|
-
test('should accept valid headers with missing
|
|
155
|
+
test('should accept valid headers with missing matcher', () => {
|
|
156
156
|
const manifest = getBaseManifest();
|
|
157
157
|
manifest.routes[0].headers = {
|
|
158
158
|
'x-custom-header': {
|
|
159
|
-
|
|
159
|
+
matcher: 'missing',
|
|
160
160
|
},
|
|
161
161
|
};
|
|
162
162
|
expect(() => validateManifest(manifest)).not.toThrowError();
|
|
163
163
|
});
|
|
164
|
-
test('should accept valid headers with regex
|
|
164
|
+
test('should accept valid headers with regex matcher and pattern', () => {
|
|
165
165
|
const manifest = getBaseManifest();
|
|
166
166
|
manifest.routes[0].headers = {
|
|
167
167
|
'x-custom-header': {
|
|
168
|
-
|
|
168
|
+
matcher: 'regex',
|
|
169
169
|
pattern: '^Bearer .+$',
|
|
170
170
|
},
|
|
171
171
|
};
|
|
172
172
|
expect(() => validateManifest(manifest)).not.toThrowError();
|
|
173
173
|
});
|
|
174
|
-
test('should throw on missing
|
|
174
|
+
test('should throw on missing matcher property', () => {
|
|
175
175
|
const manifest = getBaseManifest();
|
|
176
176
|
manifest.routes[0].headers = {
|
|
177
177
|
'x-custom-header': {
|
|
@@ -180,20 +180,20 @@ describe('route headers', () => {
|
|
|
180
180
|
};
|
|
181
181
|
expect(() => validateManifest(manifest)).toThrowErrorMatchingSnapshot();
|
|
182
182
|
});
|
|
183
|
-
test('should throw on invalid
|
|
183
|
+
test('should throw on invalid matcher value', () => {
|
|
184
184
|
const manifest = getBaseManifest();
|
|
185
185
|
manifest.routes[0].headers = {
|
|
186
186
|
'x-custom-header': {
|
|
187
|
-
|
|
187
|
+
matcher: 'invalid',
|
|
188
188
|
},
|
|
189
189
|
};
|
|
190
190
|
expect(() => validateManifest(manifest)).toThrowErrorMatchingSnapshot();
|
|
191
191
|
});
|
|
192
|
-
test('should throw when
|
|
192
|
+
test('should throw when matcher is regex but pattern is missing', () => {
|
|
193
193
|
const manifest = getBaseManifest();
|
|
194
194
|
manifest.routes[0].headers = {
|
|
195
195
|
'x-custom-header': {
|
|
196
|
-
|
|
196
|
+
matcher: 'regex',
|
|
197
197
|
},
|
|
198
198
|
};
|
|
199
199
|
expect(() => validateManifest(manifest)).toThrowErrorMatchingSnapshot();
|
|
@@ -202,7 +202,7 @@ describe('route headers', () => {
|
|
|
202
202
|
const manifest = getBaseManifest();
|
|
203
203
|
manifest.routes[0].headers = {
|
|
204
204
|
'x-custom-header': {
|
|
205
|
-
|
|
205
|
+
matcher: 'regex',
|
|
206
206
|
pattern: '/^Bearer .+/',
|
|
207
207
|
},
|
|
208
208
|
};
|
|
@@ -212,23 +212,23 @@ describe('route headers', () => {
|
|
|
212
212
|
const manifest = getBaseManifest();
|
|
213
213
|
manifest.routes[0].headers = {
|
|
214
214
|
'x-custom-header': {
|
|
215
|
-
|
|
215
|
+
matcher: 'exists',
|
|
216
216
|
foo: 'bar',
|
|
217
217
|
},
|
|
218
218
|
};
|
|
219
219
|
expect(() => validateManifest(manifest)).toThrowErrorMatchingSnapshot();
|
|
220
220
|
});
|
|
221
|
-
test('should accept multiple headers with different
|
|
221
|
+
test('should accept multiple headers with different matchers', () => {
|
|
222
222
|
const manifest = getBaseManifest();
|
|
223
223
|
manifest.routes[0].headers = {
|
|
224
224
|
'x-exists-header': {
|
|
225
|
-
|
|
225
|
+
matcher: 'exists',
|
|
226
226
|
},
|
|
227
227
|
'x-missing-header': {
|
|
228
|
-
|
|
228
|
+
matcher: 'missing',
|
|
229
229
|
},
|
|
230
230
|
authorization: {
|
|
231
|
-
|
|
231
|
+
matcher: 'regex',
|
|
232
232
|
pattern: '^Bearer [a-zA-Z0-9]+$',
|
|
233
233
|
},
|
|
234
234
|
};
|
|
@@ -68,7 +68,7 @@ declare const edgeManifestSchema: {
|
|
|
68
68
|
type: string;
|
|
69
69
|
format: string;
|
|
70
70
|
};
|
|
71
|
-
|
|
71
|
+
matcher: {
|
|
72
72
|
type: string;
|
|
73
73
|
enum: string[];
|
|
74
74
|
};
|
|
@@ -76,7 +76,7 @@ declare const edgeManifestSchema: {
|
|
|
76
76
|
additionalProperties: boolean;
|
|
77
77
|
if: {
|
|
78
78
|
properties: {
|
|
79
|
-
|
|
79
|
+
matcher: {
|
|
80
80
|
const: string;
|
|
81
81
|
};
|
|
82
82
|
};
|
|
@@ -141,7 +141,7 @@ declare const edgeManifestSchema: {
|
|
|
141
141
|
type: string;
|
|
142
142
|
format: string;
|
|
143
143
|
};
|
|
144
|
-
|
|
144
|
+
matcher: {
|
|
145
145
|
type: string;
|
|
146
146
|
enum: string[];
|
|
147
147
|
};
|
|
@@ -149,7 +149,7 @@ declare const edgeManifestSchema: {
|
|
|
149
149
|
additionalProperties: boolean;
|
|
150
150
|
if: {
|
|
151
151
|
properties: {
|
|
152
|
-
|
|
152
|
+
matcher: {
|
|
153
153
|
const: string;
|
|
154
154
|
};
|
|
155
155
|
};
|
|
@@ -20,13 +20,13 @@ const headersSchema = {
|
|
|
20
20
|
patternProperties: {
|
|
21
21
|
'.*': {
|
|
22
22
|
type: 'object',
|
|
23
|
-
required: ['
|
|
23
|
+
required: ['matcher'],
|
|
24
24
|
properties: {
|
|
25
25
|
pattern: {
|
|
26
26
|
type: 'string',
|
|
27
27
|
format: 'regexPattern',
|
|
28
28
|
},
|
|
29
|
-
|
|
29
|
+
matcher: {
|
|
30
30
|
type: 'string',
|
|
31
31
|
enum: ['exists', 'missing', 'regex'],
|
|
32
32
|
},
|
|
@@ -34,7 +34,7 @@ const headersSchema = {
|
|
|
34
34
|
additionalProperties: false,
|
|
35
35
|
if: {
|
|
36
36
|
properties: {
|
|
37
|
-
|
|
37
|
+
matcher: { const: 'regex' },
|
|
38
38
|
},
|
|
39
39
|
},
|
|
40
40
|
then: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/edge-bundler",
|
|
3
|
-
"version": "14.2.
|
|
3
|
+
"version": "14.2.2",
|
|
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": "8b7583e1890636bd64b54e20aee40ae5365edeaf"
|
|
85
85
|
}
|