@netlify/edge-bundler 1.0.0 → 1.1.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.
Files changed (2) hide show
  1. package/dist/manifest.js +14 -1
  2. package/package.json +3 -1
package/dist/manifest.js CHANGED
@@ -9,7 +9,7 @@ const generateManifest = ({ bundles = [], declarations = [], functions }) => {
9
9
  if (func === undefined) {
10
10
  return;
11
11
  }
12
- const pattern = 'pattern' in declaration ? new RegExp(declaration.pattern) : globToRegExp(declaration.path);
12
+ const pattern = getRegularExpression(declaration);
13
13
  const serializablePattern = pattern.source.replace(/\\\//g, '/');
14
14
  return {
15
15
  function: func.name,
@@ -27,6 +27,19 @@ const generateManifest = ({ bundles = [], declarations = [], functions }) => {
27
27
  };
28
28
  return manifest;
29
29
  };
30
+ const getRegularExpression = (declaration) => {
31
+ if ('pattern' in declaration) {
32
+ return new RegExp(declaration.pattern);
33
+ }
34
+ // We use the global flag so that `globToRegExp` will not wrap the expression
35
+ // with `^` and `$`. We'll do that ourselves.
36
+ const regularExpression = globToRegExp(declaration.path, { flags: 'g' });
37
+ // Wrapping the expression source with `^` and `$`. Also, adding an optional
38
+ // trailing slash, so that a declaration of `path: "/foo"` matches requests
39
+ // for both `/foo` and `/foo/`.
40
+ const normalizedSource = `^${regularExpression.source}\\/?$`;
41
+ return new RegExp(normalizedSource);
42
+ };
30
43
  const writeManifest = ({ bundles, declarations = [], distDirectory, functions }) => {
31
44
  const manifest = generateManifest({ bundles, declarations, functions });
32
45
  const manifestPath = join(distDirectory, 'manifest.json');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/edge-bundler",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Intelligently prepare Netlify Edge Functions for deployment",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -66,8 +66,10 @@
66
66
  "@types/semver": "^7.3.9",
67
67
  "@types/sinon": "^10.0.8",
68
68
  "@types/uuid": "^8.3.4",
69
+ "archiver": "^5.3.1",
69
70
  "ava": "^4.0.1",
70
71
  "husky": "^7.0.4",
72
+ "nock": "^13.2.4",
71
73
  "nyc": "^15.0.0",
72
74
  "sinon": "^12.0.1",
73
75
  "ts-node": "^10.4.0",