Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure routeKeys are PCRE compliant #14987

Merged
merged 2 commits into from
Jul 8, 2020
Merged

Conversation

ijjk
Copy link
Member

@ijjk ijjk commented Jul 8, 2020

This adds additional checks against the routeKeys used to build the named regexes for dynamic routes to ensure they follow PCRE rules for named capture groups

x-ref: vercel/vercel#4813

@ijjk
Copy link
Member Author

ijjk commented Jul 8, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary ijjk/next.js fix/named-regexes Change
buildDuration 11s 10.8s -262ms
nodeModulesSize 66.1 MB 66.1 MB ⚠️ +2.48 kB
Page Load Tests Overall increase ✓
vercel/next.js canary ijjk/next.js fix/named-regexes Change
/ failed reqs 0 0
/ total time (seconds) 1.785 1.808 ⚠️ +0.02
/ avg req/sec 1400.71 1383.07 ⚠️ -17.64
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.093 1.074 -0.02
/error-in-render avg req/sec 2288.12 2327.52 +39.4
Client Bundles (main, webpack, commons)
vercel/next.js canary ijjk/next.js fix/named-regexes Change
main-HASH.js gzip 6.63 kB 6.63 kB
webpack-HASH.js gzip 751 B 751 B
19b7e98f51cc..c646.js gzip 10.7 kB 10.7 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 57.2 kB 57.2 kB
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary ijjk/next.js fix/named-regexes Change
main-HASH.module.js gzip 5.71 kB 5.71 kB
webpack-HASH..dule.js gzip 751 B 751 B
19b7e98f51cc..dule.js gzip 7.1 kB 7.1 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 52.7 kB 52.7 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary ijjk/next.js fix/named-regexes Change
polyfills-HASH.js gzip 26.4 kB 26.4 kB
Overall change 26.4 kB 26.4 kB
Client Build Manifests
vercel/next.js canary ijjk/next.js fix/named-regexes Change
_buildManifest.js gzip 268 B 268 B
_buildManife..dule.js gzip 272 B 272 B
Overall change 540 B 540 B
Rendered Page Sizes Overall increase ⚠️
vercel/next.js canary ijjk/next.js fix/named-regexes Change
index.html gzip 954 B 954 B
link.html gzip 960 B 962 B ⚠️ +2 B
withRouter.html gzip 946 B 946 B
Overall change 2.86 kB 2.86 kB ⚠️ +2 B

Diffs

Diff for 19b7e98f51cc..73.module.js
@@ -544,7 +544,11 @@
         // while generating routes-manifest
 
         if (false) {
-          var namedParameterizedRoute, routeKeys;
+          var namedParameterizedRoute,
+            routeKeys,
+            getSafeRouteKey,
+            routeKeyCharLength,
+            routeKeyCharCode;
         }
 
         return {
Diff for 19b7e98f51cc..d0645a966.js
@@ -624,7 +624,11 @@
         // while generating routes-manifest
 
         if (false) {
-          var namedParameterizedRoute, routeKeys;
+          var namedParameterizedRoute,
+            routeKeys,
+            getSafeRouteKey,
+            routeKeyCharLength,
+            routeKeyCharCode;
         }
 
         return {
Diff for index.html
@@ -24,7 +24,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.6892bb0ce1e47d97f973.module.js"
+      href="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.81cf701752e54f994ede.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -117,13 +117,13 @@
       type="module"
     ></script>
     <script
-      src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.ee8f39bc6cdd0645a966.js"
+      src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.57653bae0c6b697ae7df.js"
       async=""
       crossorigin="anonymous"
       nomodule=""
     ></script>
     <script
-      src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.6892bb0ce1e47d97f973.module.js"
+      src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.81cf701752e54f994ede.module.js"
       async=""
       crossorigin="anonymous"
       type="module"
Diff for link.html
@@ -24,7 +24,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.6892bb0ce1e47d97f973.module.js"
+      href="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.81cf701752e54f994ede.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -122,13 +122,13 @@
       type="module"
     ></script>
     <script
-      src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.ee8f39bc6cdd0645a966.js"
+      src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.57653bae0c6b697ae7df.js"
       async=""
       crossorigin="anonymous"
       nomodule=""
     ></script>
     <script
-      src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.6892bb0ce1e47d97f973.module.js"
+      src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.81cf701752e54f994ede.module.js"
       async=""
       crossorigin="anonymous"
       type="module"
Diff for withRouter.html
@@ -24,7 +24,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.6892bb0ce1e47d97f973.module.js"
+      href="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.81cf701752e54f994ede.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -117,13 +117,13 @@
       type="module"
     ></script>
     <script
-      src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.ee8f39bc6cdd0645a966.js"
+      src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.57653bae0c6b697ae7df.js"
       async=""
       crossorigin="anonymous"
       nomodule=""
     ></script>
     <script
-      src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.6892bb0ce1e47d97f973.module.js"
+      src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.81cf701752e54f994ede.module.js"
       async=""
       crossorigin="anonymous"
       type="module"

Serverless Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary ijjk/next.js fix/named-regexes Change
buildDuration 11.7s 11.6s -79ms
nodeModulesSize 66.1 MB 66.1 MB ⚠️ +2.48 kB
Client Bundles (main, webpack, commons)
vercel/next.js canary ijjk/next.js fix/named-regexes Change
main-HASH.js gzip 6.63 kB 6.63 kB
webpack-HASH.js gzip 751 B 751 B
19b7e98f51cc..c646.js gzip 10.7 kB N/A N/A
framework.HASH.js gzip 39.1 kB 39.1 kB
19b7e98f51cc..e4a8.js gzip N/A 10.7 kB N/A
Overall change 57.2 kB 57.2 kB
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary ijjk/next.js fix/named-regexes Change
main-HASH.module.js gzip 5.71 kB 5.71 kB
webpack-HASH..dule.js gzip 751 B 751 B
19b7e98f51cc..dule.js gzip 7.1 kB N/A N/A
framework.HA..dule.js gzip 39.1 kB 39.1 kB
19b7e98f51cc..dule.js gzip N/A 7.1 kB N/A
Overall change 52.7 kB 52.7 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary ijjk/next.js fix/named-regexes Change
polyfills-HASH.js gzip 26.4 kB 26.4 kB
Overall change 26.4 kB 26.4 kB
Client Build Manifests
vercel/next.js canary ijjk/next.js fix/named-regexes Change
_buildManifest.js gzip 268 B 268 B
_buildManife..dule.js gzip 272 B 272 B
Overall change 540 B 540 B
Serverless bundles Overall increase ⚠️
vercel/next.js canary ijjk/next.js fix/named-regexes Change
_error.js 876 kB 876 kB
404.html 4.17 kB 4.17 kB
hooks.html 3.79 kB 3.79 kB
index.js 877 kB 877 kB
link.js 915 kB 916 kB ⚠️ +896 B
routerDirect.js 909 kB 910 kB ⚠️ +896 B
withRouter.js 909 kB 910 kB ⚠️ +896 B
Overall change 4.49 MB 4.5 MB ⚠️ +2.69 kB
Commit: b02b1fe

@ijjk
Copy link
Member Author

ijjk commented Jul 8, 2020

Stats from current PR

Default Server Mode (Decrease detected ✓)
General Overall increase ⚠️
vercel/next.js canary ijjk/next.js fix/named-regexes Change
buildDuration 10.5s 10.2s -346ms
nodeModulesSize 66.1 MB 66.1 MB ⚠️ +3.63 kB
Page Load Tests Overall decrease ⚠️
vercel/next.js canary ijjk/next.js fix/named-regexes Change
/ failed reqs 0 0
/ total time (seconds) 1.672 1.68 ⚠️ +0.01
/ avg req/sec 1495.12 1488.01 ⚠️ -7.11
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.005 1.013 ⚠️ +0.01
/error-in-render avg req/sec 2488.37 2467.53 ⚠️ -20.84
Client Bundles (main, webpack, commons)
vercel/next.js canary ijjk/next.js fix/named-regexes Change
main-HASH.js gzip 6.63 kB 6.63 kB
webpack-HASH.js gzip 751 B 751 B
19b7e98f51cc..c646.js gzip 10.7 kB 10.7 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 57.2 kB 57.2 kB
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary ijjk/next.js fix/named-regexes Change
main-HASH.module.js gzip 5.71 kB 5.71 kB
webpack-HASH..dule.js gzip 751 B 751 B
19b7e98f51cc..dule.js gzip 7.1 kB 7.1 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 52.7 kB 52.7 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary ijjk/next.js fix/named-regexes Change
polyfills-HASH.js gzip 26.4 kB 26.4 kB
Overall change 26.4 kB 26.4 kB
Client Build Manifests
vercel/next.js canary ijjk/next.js fix/named-regexes Change
_buildManifest.js gzip 268 B 268 B
_buildManife..dule.js gzip 272 B 272 B
Overall change 540 B 540 B
Rendered Page Sizes Overall increase ⚠️
vercel/next.js canary ijjk/next.js fix/named-regexes Change
index.html gzip 954 B 954 B
link.html gzip 960 B 962 B ⚠️ +2 B
withRouter.html gzip 946 B 946 B
Overall change 2.86 kB 2.86 kB ⚠️ +2 B

Diffs

Diff for 19b7e98f51cc..73.module.js
@@ -544,7 +544,11 @@
         // while generating routes-manifest
 
         if (false) {
-          var namedParameterizedRoute, routeKeys;
+          var namedParameterizedRoute,
+            routeKeys,
+            getSafeRouteKey,
+            routeKeyCharLength,
+            routeKeyCharCode;
         }
 
         return {
Diff for 19b7e98f51cc..d0645a966.js
@@ -624,7 +624,11 @@
         // while generating routes-manifest
 
         if (false) {
-          var namedParameterizedRoute, routeKeys;
+          var namedParameterizedRoute,
+            routeKeys,
+            getSafeRouteKey,
+            routeKeyCharLength,
+            routeKeyCharCode;
         }
 
         return {
Diff for index.html
@@ -24,7 +24,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.6892bb0ce1e47d97f973.module.js"
+      href="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.81cf701752e54f994ede.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -117,13 +117,13 @@
       type="module"
     ></script>
     <script
-      src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.ee8f39bc6cdd0645a966.js"
+      src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.57653bae0c6b697ae7df.js"
       async=""
       crossorigin="anonymous"
       nomodule=""
     ></script>
     <script
-      src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.6892bb0ce1e47d97f973.module.js"
+      src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.81cf701752e54f994ede.module.js"
       async=""
       crossorigin="anonymous"
       type="module"
Diff for link.html
@@ -24,7 +24,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.6892bb0ce1e47d97f973.module.js"
+      href="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.81cf701752e54f994ede.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -122,13 +122,13 @@
       type="module"
     ></script>
     <script
-      src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.ee8f39bc6cdd0645a966.js"
+      src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.57653bae0c6b697ae7df.js"
       async=""
       crossorigin="anonymous"
       nomodule=""
     ></script>
     <script
-      src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.6892bb0ce1e47d97f973.module.js"
+      src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.81cf701752e54f994ede.module.js"
       async=""
       crossorigin="anonymous"
       type="module"
Diff for withRouter.html
@@ -24,7 +24,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.6892bb0ce1e47d97f973.module.js"
+      href="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.81cf701752e54f994ede.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -117,13 +117,13 @@
       type="module"
     ></script>
     <script
-      src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.ee8f39bc6cdd0645a966.js"
+      src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.57653bae0c6b697ae7df.js"
       async=""
       crossorigin="anonymous"
       nomodule=""
     ></script>
     <script
-      src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.6892bb0ce1e47d97f973.module.js"
+      src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.81cf701752e54f994ede.module.js"
       async=""
       crossorigin="anonymous"
       type="module"

Serverless Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary ijjk/next.js fix/named-regexes Change
buildDuration 11.3s 11.9s ⚠️ +579ms
nodeModulesSize 66.1 MB 66.1 MB ⚠️ +3.63 kB
Client Bundles (main, webpack, commons)
vercel/next.js canary ijjk/next.js fix/named-regexes Change
main-HASH.js gzip 6.63 kB 6.63 kB
webpack-HASH.js gzip 751 B 751 B
19b7e98f51cc..c646.js gzip 10.7 kB N/A N/A
framework.HASH.js gzip 39.1 kB 39.1 kB
19b7e98f51cc..e4a8.js gzip N/A 10.7 kB N/A
Overall change 57.2 kB 57.2 kB
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary ijjk/next.js fix/named-regexes Change
main-HASH.module.js gzip 5.71 kB 5.71 kB
webpack-HASH..dule.js gzip 751 B 751 B
19b7e98f51cc..dule.js gzip 7.1 kB N/A N/A
framework.HA..dule.js gzip 39.1 kB 39.1 kB
19b7e98f51cc..dule.js gzip N/A 7.1 kB N/A
Overall change 52.7 kB 52.7 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary ijjk/next.js fix/named-regexes Change
polyfills-HASH.js gzip 26.4 kB 26.4 kB
Overall change 26.4 kB 26.4 kB
Client Build Manifests
vercel/next.js canary ijjk/next.js fix/named-regexes Change
_buildManifest.js gzip 268 B 268 B
_buildManife..dule.js gzip 272 B 272 B
Overall change 540 B 540 B
Serverless bundles Overall increase ⚠️
vercel/next.js canary ijjk/next.js fix/named-regexes Change
_error.js 876 kB 876 kB -20 B
404.html 4.17 kB 4.17 kB
hooks.html 3.79 kB 3.79 kB
index.js 877 kB 877 kB -20 B
link.js 915 kB 916 kB ⚠️ +876 B
routerDirect.js 909 kB 909 kB ⚠️ +876 B
withRouter.js 909 kB 910 kB ⚠️ +876 B
Overall change 4.49 MB 4.5 MB ⚠️ +2.59 kB
Commit: efcfb4c

Copy link
Contributor

@dav-is dav-is left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great

@kodiakhq kodiakhq bot merged commit 16590f7 into vercel:canary Jul 8, 2020
@timneutkens timneutkens deleted the fix/named-regexes branch July 8, 2020 18:46
rokinsky pushed a commit to rokinsky/next.js that referenced this pull request Jul 11, 2020
This adds additional checks against the routeKeys used to build the named regexes for dynamic routes to ensure they follow PCRE rules for named capture groups

x-ref: vercel/vercel#4813
@vercel vercel locked as resolved and limited conversation to collaborators Jan 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants