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

Ensure href is updated for locale domain #20631

Merged
merged 3 commits into from
Dec 31, 2020
Merged

Conversation

ijjk
Copy link
Member

@ijjk ijjk commented Dec 31, 2020

This ensures we render the locale domain on the href when using next/link previously the provided href was stilling being rendered which differed from the resulting href that was navigated to.

Fixes: #20612

@vercel vercel bot temporarily deployed to Preview December 31, 2020 04:32 Inactive
@ijjk

This comment has been minimized.

@vercel vercel bot temporarily deployed to Preview December 31, 2020 04:47 Inactive
@ijjk
Copy link
Member Author

ijjk commented Dec 31, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary ijjk/next.js i18n-domain-links Change
buildDuration 8.4s 8.5s ⚠️ +52ms
nodeModulesSize 83 MB 83 MB ⚠️ +2.73 kB
Page Load Tests Overall decrease ⚠️
vercel/next.js canary ijjk/next.js i18n-domain-links Change
/ failed reqs 0 0
/ total time (seconds) 1.776 1.858 ⚠️ +0.08
/ avg req/sec 1407.28 1345.82 ⚠️ -61.46
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.177 1.161 -0.02
/error-in-render avg req/sec 2123.17 2153.72 +30.55
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary ijjk/next.js i18n-domain-links Change
677f882d2ed8..6cec.js gzip 12.8 kB 12.8 kB ⚠️ +16 B
framework.HASH.js gzip 39 kB 39 kB
main-b45d971..6435.js gzip 6.59 kB 6.59 kB
webpack-7193..1446.js gzip 751 B 751 B
Overall change 59.1 kB 59.1 kB ⚠️ +16 B
Legacy Client Bundles (polyfills)
vercel/next.js canary ijjk/next.js i18n-domain-links Change
polyfills-67..b7d1.js gzip 31.2 kB 31.2 kB
Overall change 31.2 kB 31.2 kB
Client Pages Overall increase ⚠️
vercel/next.js canary ijjk/next.js i18n-domain-links Change
_app-6220e08..9a40.js gzip 1.28 kB 1.28 kB
_error-4b0b5..2c91.js gzip 3.44 kB 3.44 kB
hooks-5f309a..7282.js gzip 887 B 887 B
index-57f580..c562.js gzip 227 B 227 B
link-1a1f628..eeb5.js gzip 1.61 kB 1.64 kB ⚠️ +28 B
routerDirect..bd82.js gzip 303 B 303 B
withRouter-2..e384.js gzip 302 B 302 B
Overall change 8.05 kB 8.08 kB ⚠️ +28 B
Client Build Manifests Overall decrease ✓
vercel/next.js canary ijjk/next.js i18n-domain-links Change
_buildManifest.js gzip 322 B 321 B -1 B
Overall change 322 B 321 B -1 B
Rendered Page Sizes Overall increase ⚠️
vercel/next.js canary ijjk/next.js i18n-domain-links Change
index.html gzip 617 B 617 B
link.html gzip 622 B 622 B
withRouter.html gzip 610 B 611 B ⚠️ +1 B
Overall change 1.85 kB 1.85 kB ⚠️ +1 B

Diffs

Diff for _buildManifest.js
@@ -7,7 +7,7 @@ self.__BUILD_MANIFEST = {
   "/hooks": [
     "static\u002Fchunks\u002Fpages\u002Fhooks-61cb7b66e376b851f63a.js"
   ],
-  "/link": ["static\u002Fchunks\u002Fpages\u002Flink-93d772b087df6a15801f.js"],
+  "/link": ["static\u002Fchunks\u002Fpages\u002Flink-e404e0ff0d1ed82dadd1.js"],
   "/routerDirect": [
     "static\u002Fchunks\u002Fpages\u002FrouterDirect-a5bdcfc87579b1d2776d.js"
   ],
Diff for link-93d772b..f6a15801f.js
@@ -284,13 +284,23 @@ _N_E = (window["webpackJsonp_N_E"] = window["webpackJsonp_N_E"] || []).push([
           props.passHref ||
           (child.type === "a" && !("href" in child.props))
         ) {
-          childProps.href = (0, _router.addBasePath)(
-            (0, _router.addLocale)(
-              as,
-              typeof locale !== "undefined" ? locale : router && router.locale,
-              router && router.defaultLocale
-            )
+          var curLocale =
+            typeof locale !== "undefined" ? locale : router && router.locale;
+          var localeDomain = (0, _router.getDomainLocale)(
+            as,
+            curLocale,
+            router && router.locales,
+            router && router.domainLocales
           );
+          childProps.href =
+            localeDomain ||
+            (0, _router.addBasePath)(
+              (0, _router.addLocale)(
+                as,
+                curLocale,
+                router && router.defaultLocale
+              )
+            );
         }
 
         return /*#__PURE__*/ _react["default"].cloneElement(child, childProps);
Diff for 677f882d2ed8..74301f1c8.js
@@ -1178,6 +1178,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
       var _slicedToArray = __webpack_require__("J4zp");
 
       exports.__esModule = true;
+      exports.getDomainLocale = getDomainLocale;
       exports.addLocale = addLocale;
       exports.delLocale = delLocale;
       exports.hasBasePath = hasBasePath;
@@ -1245,6 +1246,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
           : path;
       }
 
+      function getDomainLocale(path, locale, locales, domainLocales) {
+        if (false) {
+          var detectedDomain;
+        }
+
+        return false;
+      }
+
       function addLocale(path, locale, defaultLocale) {
         if (false) {
         }
Diff for index.html
@@ -22,7 +22,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3bda7895f2274301f1c8.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.bab86a96808e16684765.js"
       as="script"
     />
     <link
@@ -65,7 +65,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3bda7895f2274301f1c8.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.bab86a96808e16684765.js"
       async=""
     ></script>
     <script
Diff for link.html
@@ -22,7 +22,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3bda7895f2274301f1c8.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.bab86a96808e16684765.js"
       as="script"
     />
     <link
@@ -32,7 +32,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/pages/link-93d772b087df6a15801f.js"
+      href="/_next/static/chunks/pages/link-e404e0ff0d1ed82dadd1.js"
       as="script"
     />
   </head>
@@ -70,7 +70,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3bda7895f2274301f1c8.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.bab86a96808e16684765.js"
       async=""
     ></script>
     <script
@@ -78,7 +78,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/pages/link-93d772b087df6a15801f.js"
+      src="/_next/static/chunks/pages/link-e404e0ff0d1ed82dadd1.js"
       async=""
     ></script>
     <script src="/_next/static/BUILD_ID/_buildManifest.js" async=""></script>
Diff for withRouter.html
@@ -22,7 +22,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3bda7895f2274301f1c8.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.bab86a96808e16684765.js"
       as="script"
     />
     <link
@@ -65,7 +65,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3bda7895f2274301f1c8.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.bab86a96808e16684765.js"
       async=""
     ></script>
     <script

Serverless Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary ijjk/next.js i18n-domain-links Change
buildDuration 11.1s 9.5s -1.7s
nodeModulesSize 83 MB 83 MB ⚠️ +2.73 kB
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary ijjk/next.js i18n-domain-links Change
677f882d2ed8..6cec.js gzip 12.8 kB N/A N/A
framework.HASH.js gzip 39 kB 39 kB
main-b45d971..6435.js gzip 6.59 kB 6.59 kB
webpack-7193..1446.js gzip 751 B 751 B
677f882d2ed8..8a8f.js gzip N/A 12.8 kB N/A
Overall change 59.1 kB 59.1 kB ⚠️ +16 B
Legacy Client Bundles (polyfills)
vercel/next.js canary ijjk/next.js i18n-domain-links Change
polyfills-67..b7d1.js gzip 31.2 kB 31.2 kB
Overall change 31.2 kB 31.2 kB
Client Pages Overall increase ⚠️
vercel/next.js canary ijjk/next.js i18n-domain-links Change
_app-6220e08..9a40.js gzip 1.28 kB 1.28 kB
_error-4b0b5..2c91.js gzip 3.44 kB 3.44 kB
hooks-5f309a..7282.js gzip 887 B 887 B
index-57f580..c562.js gzip 227 B 227 B
link-1a1f628..eeb5.js gzip 1.61 kB N/A N/A
routerDirect..bd82.js gzip 303 B 303 B
withRouter-2..e384.js gzip 302 B 302 B
link-b862cd7..dba8.js gzip N/A 1.64 kB N/A
Overall change 8.05 kB 8.08 kB ⚠️ +28 B
Client Build Manifests Overall decrease ✓
vercel/next.js canary ijjk/next.js i18n-domain-links Change
_buildManifest.js gzip 322 B 321 B -1 B
Overall change 322 B 321 B -1 B
Serverless bundles Overall increase ⚠️
vercel/next.js canary ijjk/next.js i18n-domain-links Change
_error.js 1 MB 1 MB ⚠️ +98 B
404.html 2.67 kB 2.67 kB
hooks.html 1.92 kB 1.92 kB
index.js 1 MB 1 MB ⚠️ +98 B
link.js 1.06 MB 1.06 MB ⚠️ +419 B
routerDirect.js 1.05 MB 1.05 MB ⚠️ +242 B
withRouter.js 1.05 MB 1.05 MB ⚠️ +242 B
Overall change 5.17 MB 5.17 MB ⚠️ +1.1 kB
Commit: 0935aee

@ijjk ijjk marked this pull request as ready for review December 31, 2020 05:08
@vercel vercel bot temporarily deployed to Preview December 31, 2020 07:34 Inactive
@ijjk
Copy link
Member Author

ijjk commented Dec 31, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary ijjk/next.js i18n-domain-links Change
buildDuration 9.8s 9.7s -63ms
nodeModulesSize 83 MB 83 MB ⚠️ +2.73 kB
Page Load Tests Overall increase ✓
vercel/next.js canary ijjk/next.js i18n-domain-links Change
/ failed reqs 0 0
/ total time (seconds) 1.943 1.913 -0.03
/ avg req/sec 1286.98 1306.86 +19.88
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.195 1.198 0
/error-in-render avg req/sec 2092.39 2086.29 ⚠️ -6.1
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary ijjk/next.js i18n-domain-links Change
677f882d2ed8..6cec.js gzip 12.8 kB 12.8 kB ⚠️ +16 B
framework.HASH.js gzip 39 kB 39 kB
main-5b13c61..eaca.js gzip 6.59 kB 6.59 kB
webpack-7193..1446.js gzip 751 B 751 B
Overall change 59.1 kB 59.1 kB ⚠️ +16 B
Legacy Client Bundles (polyfills)
vercel/next.js canary ijjk/next.js i18n-domain-links Change
polyfills-67..b7d1.js gzip 31.2 kB 31.2 kB
Overall change 31.2 kB 31.2 kB
Client Pages Overall increase ⚠️
vercel/next.js canary ijjk/next.js i18n-domain-links Change
_app-6220e08..9a40.js gzip 1.28 kB 1.28 kB
_error-4b0b5..2c91.js gzip 3.44 kB 3.44 kB
hooks-5f309a..7282.js gzip 887 B 887 B
index-57f580..c562.js gzip 227 B 227 B
link-1a1f628..eeb5.js gzip 1.61 kB 1.64 kB ⚠️ +28 B
routerDirect..bd82.js gzip 303 B 303 B
withRouter-2..e384.js gzip 302 B 302 B
Overall change 8.05 kB 8.08 kB ⚠️ +28 B
Client Build Manifests Overall decrease ✓
vercel/next.js canary ijjk/next.js i18n-domain-links Change
_buildManifest.js gzip 322 B 321 B -1 B
Overall change 322 B 321 B -1 B
Rendered Page Sizes
vercel/next.js canary ijjk/next.js i18n-domain-links Change
index.html gzip 617 B 616 B -1 B
link.html gzip 621 B 622 B ⚠️ +1 B
withRouter.html gzip 610 B 610 B
Overall change 1.85 kB 1.85 kB

Diffs

Diff for _buildManifest.js
@@ -7,7 +7,7 @@ self.__BUILD_MANIFEST = {
   "/hooks": [
     "static\u002Fchunks\u002Fpages\u002Fhooks-61cb7b66e376b851f63a.js"
   ],
-  "/link": ["static\u002Fchunks\u002Fpages\u002Flink-93d772b087df6a15801f.js"],
+  "/link": ["static\u002Fchunks\u002Fpages\u002Flink-e404e0ff0d1ed82dadd1.js"],
   "/routerDirect": [
     "static\u002Fchunks\u002Fpages\u002FrouterDirect-a5bdcfc87579b1d2776d.js"
   ],
Diff for link-93d772b..f6a15801f.js
@@ -284,13 +284,23 @@ _N_E = (window["webpackJsonp_N_E"] = window["webpackJsonp_N_E"] || []).push([
           props.passHref ||
           (child.type === "a" && !("href" in child.props))
         ) {
-          childProps.href = (0, _router.addBasePath)(
-            (0, _router.addLocale)(
-              as,
-              typeof locale !== "undefined" ? locale : router && router.locale,
-              router && router.defaultLocale
-            )
+          var curLocale =
+            typeof locale !== "undefined" ? locale : router && router.locale;
+          var localeDomain = (0, _router.getDomainLocale)(
+            as,
+            curLocale,
+            router && router.locales,
+            router && router.domainLocales
           );
+          childProps.href =
+            localeDomain ||
+            (0, _router.addBasePath)(
+              (0, _router.addLocale)(
+                as,
+                curLocale,
+                router && router.defaultLocale
+              )
+            );
         }
 
         return /*#__PURE__*/ _react["default"].cloneElement(child, childProps);
Diff for 677f882d2ed8..74301f1c8.js
@@ -1178,6 +1178,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
       var _slicedToArray = __webpack_require__("J4zp");
 
       exports.__esModule = true;
+      exports.getDomainLocale = getDomainLocale;
       exports.addLocale = addLocale;
       exports.delLocale = delLocale;
       exports.hasBasePath = hasBasePath;
@@ -1245,6 +1246,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
           : path;
       }
 
+      function getDomainLocale(path, locale, locales, domainLocales) {
+        if (false) {
+          var detectedDomain;
+        }
+
+        return false;
+      }
+
       function addLocale(path, locale, defaultLocale) {
         if (false) {
         }
Diff for index.html
@@ -22,7 +22,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3bda7895f2274301f1c8.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.bab86a96808e16684765.js"
       as="script"
     />
     <link
@@ -65,7 +65,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3bda7895f2274301f1c8.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.bab86a96808e16684765.js"
       async=""
     ></script>
     <script
Diff for link.html
@@ -22,7 +22,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3bda7895f2274301f1c8.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.bab86a96808e16684765.js"
       as="script"
     />
     <link
@@ -32,7 +32,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/pages/link-93d772b087df6a15801f.js"
+      href="/_next/static/chunks/pages/link-e404e0ff0d1ed82dadd1.js"
       as="script"
     />
   </head>
@@ -70,7 +70,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3bda7895f2274301f1c8.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.bab86a96808e16684765.js"
       async=""
     ></script>
     <script
@@ -78,7 +78,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/pages/link-93d772b087df6a15801f.js"
+      src="/_next/static/chunks/pages/link-e404e0ff0d1ed82dadd1.js"
       async=""
     ></script>
     <script src="/_next/static/BUILD_ID/_buildManifest.js" async=""></script>
Diff for withRouter.html
@@ -22,7 +22,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3bda7895f2274301f1c8.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.bab86a96808e16684765.js"
       as="script"
     />
     <link
@@ -65,7 +65,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3bda7895f2274301f1c8.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.bab86a96808e16684765.js"
       async=""
     ></script>
     <script

Serverless Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary ijjk/next.js i18n-domain-links Change
buildDuration 11.8s 11.7s -146ms
nodeModulesSize 83 MB 83 MB ⚠️ +2.73 kB
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary ijjk/next.js i18n-domain-links Change
677f882d2ed8..6cec.js gzip 12.8 kB N/A N/A
framework.HASH.js gzip 39 kB 39 kB
main-5b13c61..eaca.js gzip 6.59 kB 6.59 kB
webpack-7193..1446.js gzip 751 B 751 B
677f882d2ed8..8a8f.js gzip N/A 12.8 kB N/A
Overall change 59.1 kB 59.1 kB ⚠️ +16 B
Legacy Client Bundles (polyfills)
vercel/next.js canary ijjk/next.js i18n-domain-links Change
polyfills-67..b7d1.js gzip 31.2 kB 31.2 kB
Overall change 31.2 kB 31.2 kB
Client Pages Overall increase ⚠️
vercel/next.js canary ijjk/next.js i18n-domain-links Change
_app-6220e08..9a40.js gzip 1.28 kB 1.28 kB
_error-4b0b5..2c91.js gzip 3.44 kB 3.44 kB
hooks-5f309a..7282.js gzip 887 B 887 B
index-57f580..c562.js gzip 227 B 227 B
link-1a1f628..eeb5.js gzip 1.61 kB N/A N/A
routerDirect..bd82.js gzip 303 B 303 B
withRouter-2..e384.js gzip 302 B 302 B
link-b862cd7..dba8.js gzip N/A 1.64 kB N/A
Overall change 8.05 kB 8.08 kB ⚠️ +28 B
Client Build Manifests Overall decrease ✓
vercel/next.js canary ijjk/next.js i18n-domain-links Change
_buildManifest.js gzip 322 B 321 B -1 B
Overall change 322 B 321 B -1 B
Serverless bundles Overall increase ⚠️
vercel/next.js canary ijjk/next.js i18n-domain-links Change
_error.js 1 MB 1 MB ⚠️ +98 B
404.html 2.67 kB 2.67 kB
hooks.html 1.92 kB 1.92 kB
index.js 1 MB 1 MB ⚠️ +98 B
link.js 1.06 MB 1.06 MB ⚠️ +419 B
routerDirect.js 1.05 MB 1.05 MB ⚠️ +242 B
withRouter.js 1.05 MB 1.05 MB ⚠️ +242 B
Overall change 5.17 MB 5.17 MB ⚠️ +1.1 kB
Commit: 67c53e9

@kodiakhq kodiakhq bot merged commit fd33c9f into vercel:canary Dec 31, 2020
@Timer Timer deleted the i18n-domain-links branch December 31, 2020 16:26
@vercel vercel locked as resolved and limited conversation to collaborators Jan 29, 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.

New locale redirect behavior
2 participants