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

next-server

Package Overview
Dependencies
Maintainers
51
Versions
254
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-server - npm Package Compare versions

Comparing version 8.1.1-canary.54 to 8.1.1-canary.55

dist/lib/router/utils/is-dynamic.d.ts

4

dist/lib/router/router.js

@@ -12,2 +12,3 @@ "use strict";

const route_regex_1 = require("./utils/route-regex");
const is_dynamic_1 = require("./utils/is-dynamic");
function toRoute(path) {

@@ -170,4 +171,3 @@ return path.replace(/\/$/, '') || '/';

const { shallow = false } = options;
// detect dynamic routing
if (route.indexOf('/$') !== -1) {
if (is_dynamic_1.isDynamicRoute(route)) {
const { pathname: asPathname } = url_1.parse(as);

@@ -174,0 +174,0 @@ const rr = route_regex_1.getRouteRegex(route);

export { getRouteMatcher } from './route-matcher';
export { getRouteRegex } from './route-regex';
export { getSortedRoutes } from './sorted-routes';
export { isDynamicRoute } from './is-dynamic';

@@ -9,1 +9,3 @@ "use strict";

exports.getSortedRoutes = sorted_routes_1.getSortedRoutes;
var is_dynamic_1 = require("./is-dynamic");
exports.isDynamicRoute = is_dynamic_1.isDynamicRoute;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function getRouteRegex(normalizedRoute) {
// Escape all characters that could be considered RegEx
const escapedRoute = (normalizedRoute.replace(/\/$/, '') || '/').replace(/[|\\{}()[\]^$+*?.-]/g, '\\$&');
const groups = {};
let groupIndex = 1;
const parameterizedRoute = escapedRoute.replace(/\/\\\$([^\/]+?)(?=\/|$)/g, (_, $1) => ((groups[$1
// // Remove optional parameter marker
// .replace(/\\\$$/, '')
const parameterizedRoute = escapedRoute.replace(/\/\\\[([^\/]+?)\\\](?=\/|$)/g, (_, $1) => ((groups[$1
// Un-escape key
.replace(/\\([|\\{}()[\]^$+*?.-])/g, '$1')] = groupIndex++),
// // Test the route for an optional parameter
// $1.lastIndexOf('$') === $1.length - 1
// ? // Optional: match a param
// '(?:/([^/]+?))?'
// : // Required: match a param
'/([^/]+?)'));

@@ -18,0 +12,0 @@ return {

@@ -21,3 +21,3 @@ "use strict";

if (this.hasSlug) {
childrenPaths.splice(childrenPaths.indexOf('$'), 1);
childrenPaths.splice(childrenPaths.indexOf('[]'), 1);
}

@@ -28,3 +28,3 @@ const routes = childrenPaths

if (this.hasSlug) {
routes.push(...this.children.get('$')._smoosh(`${prefix}$${this.slugName}/`));
routes.push(...this.children.get('[]')._smoosh(`${prefix}[${this.slugName}]/`));
}

@@ -42,4 +42,4 @@ if (!this.placeholder) {

let [nextSegment] = urlPaths;
if (nextSegment.startsWith('$')) {
const slugName = nextSegment.substring(1);
if (nextSegment.startsWith('[') && nextSegment.endsWith(']')) {
const slugName = nextSegment.slice(1, -1);
if (this.hasSlug && slugName !== this.slugName) {

@@ -49,3 +49,3 @@ throw new Error('You cannot use different slug names for the same dynamic path.');

this.slugName = slugName;
nextSegment = '$';
nextSegment = '[]';
}

@@ -52,0 +52,0 @@ if (!this.children.has(nextSegment)) {

@@ -214,3 +214,3 @@ "use strict";

resolveApiRequest(pathname) {
return require_1.getPagePath(pathname, this.distDir, this.nextConfig.target === 'serverless');
return require_1.getPagePath(pathname, this.distDir, this.nextConfig.target === 'serverless', this.renderOpts.dev);
}

@@ -241,3 +241,3 @@ generatePublicRoutes() {

const manifest = require(this.buildManifest);
const dynamicRoutedPages = Object.keys(manifest.pages).filter(p => p.includes('/$'));
const dynamicRoutedPages = Object.keys(manifest.pages).filter(utils_1.isDynamicRoute);
return utils_1.getSortedRoutes(dynamicRoutedPages).map(page => ({

@@ -244,0 +244,0 @@ page,

export declare function pageNotFoundError(page: string): Error;
export declare function getPagePath(page: string, distDir: string, serverless: boolean): string;
export declare function getPagePath(page: string, distDir: string, serverless: boolean, dev?: boolean): string;
export declare function requirePage(page: string, distDir: string, serverless: boolean): any;

@@ -18,4 +18,4 @@ "use strict";

exports.pageNotFoundError = pageNotFoundError;
function getPagePath(page, distDir, serverless) {
const serverBuildPath = path_1.join(distDir, serverless ? constants_1.SERVERLESS_DIRECTORY : constants_1.SERVER_DIRECTORY);
function getPagePath(page, distDir, serverless, dev) {
const serverBuildPath = path_1.join(distDir, serverless && !dev ? constants_1.SERVERLESS_DIRECTORY : constants_1.SERVER_DIRECTORY);
const pagesManifest = require(path_1.join(serverBuildPath, constants_1.PAGES_MANIFEST));

@@ -22,0 +22,0 @@ try {

{
"name": "next-server",
"version": "8.1.1-canary.54",
"version": "8.1.1-canary.55",
"main": "./index.js",

@@ -73,3 +73,3 @@ "license": "MIT",

},
"gitHead": "204e5a7171acc6ed64946beb3cba7a01aac60160"
"gitHead": "516325eafc9a841219c569d8a50a83c4c0b58bca"
}
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