Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@netlify/edge-bundler

Package Overview
Dependencies
Maintainers
20
Versions
134
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@netlify/edge-bundler - npm Package Compare versions

Comparing version 8.13.2 to 8.14.0

7

dist/node/declaration.js

@@ -79,5 +79,4 @@ import regexpAST from 'regexp-tree';

export const parsePattern = (pattern) => {
// Escaping forward slashes with back slashes.
const normalizedPattern = pattern.replace(/\//g, '\\/');
const regex = regexpAST.transform(`/${normalizedPattern}/`, {
const regexp = new RegExp(pattern);
const newRegexp = regexpAST.transform(regexp, {
Assertion(path) {

@@ -103,3 +102,3 @@ // Lookaheads are not supported. If we find one, throw an error.

// Strip leading and forward slashes.
return regex.toString().slice(1, -1);
return newRegexp.toString().slice(1, -1);
};
import { test, expect } from 'vitest';
import { mergeDeclarations } from './declaration.js';
import { mergeDeclarations, parsePattern } from './declaration.js';
const deployConfigDeclarations = [];

@@ -140,1 +140,13 @@ test('Ensure the order of edge functions with FF', () => {

});
test('Does not escape front slashes in a regex pattern if they are already escaped', () => {
const regexPattern = '^(?:\\/(_next\\/data\\/[^/]{1,}))?(?:\\/([^/.]{1,}))\\/shows(?:\\/(.*))(.json)?[\\/#\\?]?$';
const expected = '^(?:\\/(_next\\/data\\/[^/]{1,}))?(?:\\/([^/.]{1,}))\\/shows(?:\\/(.*))(.json)?[\\/#\\?]?$';
const actual = parsePattern(regexPattern);
expect(actual).toEqual(expected);
});
test('Escapes front slashes in a regex pattern', () => {
const regexPattern = '^(?:/(_next/data/[^/]{1,}))?(?:/([^/.]{1,}))/shows(?:/(.*))(.json)?[/#\\?]?$';
const expected = '^(?:\\/(_next\\/data\\/[^/]{1,}))?(?:\\/([^/.]{1,}))\\/shows(?:\\/(.*))(.json)?[/#\\?]?$';
const actual = parsePattern(regexPattern);
expect(actual).toEqual(expected);
});

@@ -47,2 +47,2 @@ import type { Bundle } from './bundle.js';

declare const writeManifest: ({ distDirectory, ...rest }: WriteManifestOptions) => Promise<Manifest>;
export { generateManifest, Manifest, writeManifest };
export { generateManifest, Manifest, Route, writeManifest };
import { env } from 'process';
import { test, expect, vi } from 'vitest';
import { getRouteMatcher } from '../test/util.js';
import { BundleFormat } from './bundle.js';

@@ -59,5 +60,7 @@ import { generateManifest } from './manifest.js';

test('Generates a manifest with excluded paths and patterns', () => {
var _a, _b;
const functions = [
{ name: 'func-1', path: '/path/to/func-1.ts' },
{ name: 'func-2', path: '/path/to/func-2.ts' },
{ name: 'func-3', path: '/path/to/func-3.ts' },
];

@@ -67,2 +70,3 @@ const declarations = [

{ function: 'func-2', pattern: '^/f2/.*/?$', excludedPattern: '^/f2/exclude$' },
{ function: 'func-3', path: '/*', excludedPath: '/**/*.html' },
];

@@ -73,2 +77,3 @@ const manifest = generateManifest({ bundles: [], declarations, functions });

{ function: 'func-2', pattern: '^/f2/.*/?$' },
{ function: 'func-3', pattern: '^/.*/?$' },
];

@@ -79,5 +84,23 @@ expect(manifest.routes).toEqual(expectedRoutes);

'func-2': { excluded_patterns: ['^/f2/exclude$'] },
'func-3': { excluded_patterns: ['^/.*/.*\\.html/?$'] },
});
expect(manifest.bundler_version).toBe(env.npm_package_version);
const matcher = getRouteMatcher(manifest);
expect((_a = matcher('/f1/hello')) === null || _a === void 0 ? void 0 : _a.function).toBe('func-1');
expect((_b = matcher('/grandparent/parent/child/grandchild.html')) === null || _b === void 0 ? void 0 : _b.function).toBeUndefined();
});
test('TOML-defined paths can be combined with ISC-defined excluded paths', () => {
const functions = [{ name: 'func-1', path: '/path/to/func-1.ts' }];
const declarations = [{ function: 'func-1', path: '/f1/*' }];
const userFunctionConfig = {
'func-1': { excludedPath: '/f1/exclude' },
};
const manifest = generateManifest({ bundles: [], declarations, functions, userFunctionConfig });
const expectedRoutes = [{ function: 'func-1', pattern: '^/f1/.*/?$' }];
expect(manifest.routes).toEqual(expectedRoutes);
expect(manifest.function_config).toEqual({
'func-1': { excluded_patterns: ['^/f1/exclude/?$'] },
});
expect(manifest.bundler_version).toBe(env.npm_package_version);
});
test('Filters out internal in-source configurations in user created functions', () => {

@@ -84,0 +107,0 @@ const functions = [

@@ -0,1 +1,2 @@

import type { Manifest } from '../node/manifest.js';
declare const testLogger: import("../node/logger.js").Logger;

@@ -8,3 +9,4 @@ declare const fixturesDir: string;

}>;
declare const getRouteMatcher: (manifest: Manifest) => (candidate: string) => import("../node/manifest.js").Route | undefined;
declare const runESZIP: (eszipPath: string) => Promise<any>;
export { fixturesDir, testLogger, runESZIP, useFixture };
export { fixturesDir, getRouteMatcher, testLogger, runESZIP, useFixture };

@@ -38,2 +38,11 @@ import { promises as fs } from 'fs';

`;
const getRouteMatcher = (manifest) => (candidate) => manifest.routes.find((route) => {
const regex = new RegExp(route.pattern);
if (!regex.test(candidate)) {
return false;
}
const excludedPattern = manifest.function_config[route.function].excluded_patterns;
const isExcluded = excludedPattern.some((pattern) => new RegExp(pattern).test(candidate));
return !isExcluded;
});
const runESZIP = async (eszipPath) => {

@@ -70,2 +79,2 @@ var _a, _b, _c;

};
export { fixturesDir, testLogger, runESZIP, useFixture };
export { fixturesDir, getRouteMatcher, testLogger, runESZIP, useFixture };
{
"name": "@netlify/edge-bundler",
"version": "8.13.2",
"version": "8.14.0",
"description": "Intelligently prepare Netlify Edge Functions for deployment",

@@ -45,3 +45,3 @@ "type": "module",

"license": "MIT",
"repository": "netlify/edge-bundler",
"repository": "https://github.com/netlify/edge-bundler",
"bugs": {

@@ -48,0 +48,0 @@ "url": "https://github.com/netlify/edge-bundler/issues"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc