-
Notifications
You must be signed in to change notification settings - Fork 26.2k
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
Add warning for invalid href being passed to router #8231
Conversation
Stats from current PRClick to expand stats
|
zeit/next.js canary | ijjk/next.js invalid-href-warning | Change | |
---|---|---|---|
Build Duration | 13.9s | 13.8s | -54ms |
node_modules Size |
43.6 MB | 43.6 MB | |
Total Bundle (main, webpack, commons) Size | 206 kB | 206 kB | |
Total Bundle (main, webpack, commons) gzip Size | 67.8 kB | 67.8 kB | |
Client _app Size |
2.39 kB | 2.39 kB | ✓ |
Client _app gzip Size |
1.08 kB | 1.08 kB | ✓ |
Client _error Size |
8.22 kB | 8.22 kB | ✓ |
Client _error gzip Size |
3.16 kB | 3.16 kB | ✓ |
Client pages/index Size |
343 B | 343 B | ✓ |
Client pages/index gzip Size |
246 B | 246 B | ✓ |
Client pages/link Size |
4.08 kB | 4.08 kB | ✓ |
Client pages/link gzip Size |
1.8 kB | 1.8 kB | ✓ |
Client pages/routerDirect Size |
423 B | 423 B | ✓ |
Client pages/routerDirect gzip Size |
306 B | 306 B | ✓ |
Client pages/withRouter Size |
435 B | 435 B | ✓ |
Client pages/withRouter gzip Size |
301 B | 301 B | ✓ |
Client main Size |
15.4 kB | 15.4 kB | ✓ |
Client main gzip Size |
5.35 kB | 5.35 kB | ✓ |
Client commons Size |
188 kB | 188 kB | |
Client commons gzip Size |
61.1 kB | 61.2 kB | |
Client webpack Size |
1.53 kB | 1.53 kB | ✓ |
Client webpack gzip Size |
778 B | 778 B | ✓ |
Base Rendered Size | 1.35 kB | 1.35 kB | ✓ |
Build Dir Size | 702 kB | 703 kB |
Click to expand serverless stats ⚠️ Total Bundle Size Increase ⚠️
zeit/next.js canary | ijjk/next.js invalid-href-warning | Change | |
---|---|---|---|
Build Duration | 14s | 15.1s | |
node_modules Size |
43.6 MB | 43.6 MB | |
Total Bundle (main, webpack, commons) Size | 206 kB | 206 kB | |
Total Bundle (main, webpack, commons) gzip Size | 67.8 kB | 67.8 kB | |
Client _app Size |
2.39 kB | 2.39 kB | ✓ |
Client _app gzip Size |
1.08 kB | 1.08 kB | ✓ |
Client _error Size |
8.22 kB | 8.22 kB | ✓ |
Client _error gzip Size |
3.16 kB | 3.16 kB | ✓ |
Client pages/index Size |
343 B | 343 B | ✓ |
Client pages/index gzip Size |
246 B | 246 B | ✓ |
Client pages/link Size |
4.08 kB | 4.08 kB | ✓ |
Client pages/link gzip Size |
1.8 kB | 1.8 kB | ✓ |
Client pages/routerDirect Size |
423 B | 423 B | ✓ |
Client pages/routerDirect gzip Size |
306 B | 306 B | ✓ |
Client pages/withRouter Size |
435 B | 435 B | ✓ |
Client pages/withRouter gzip Size |
301 B | 301 B | ✓ |
Client main Size |
15.4 kB | 15.4 kB | ✓ |
Client main gzip Size |
5.35 kB | 5.35 kB | ✓ |
Client commons Size |
188 kB | 188 kB | |
Client commons gzip Size |
61.1 kB | 61.2 kB | |
Client webpack Size |
1.53 kB | 1.53 kB | ✓ |
Client webpack gzip Size |
778 B | 778 B | ✓ |
Serverless pages/link Size |
251 kB | 251 kB | |
Serverless pages/link gzip Size |
67.8 kB | 67.9 kB | |
Serverless pages/index Size |
244 kB | 244 kB | |
Serverless pages/index gzip Size |
65.6 kB | 65.7 kB | |
Serverless pages/_error Size |
243 kB | 244 kB | |
Serverless pages/_error gzip Size |
65.4 kB | 65.4 kB | |
Serverless pages/routerDirect Size |
244 kB | 245 kB | |
Serverless pages/routerDirect gzip Size |
65.6 kB | 65.6 kB | |
Serverless pages/withRouter Size |
244 kB | 245 kB | |
Serverless pages/withRouter gzip Size |
65.7 kB | 65.8 kB | |
Build Dir Size | 1.89 MB | 1.89 MB |
Diff for commons.js
@@ -3009,6 +3009,10 @@ function toRoute(path) {
return path.replace(/\/$/, '') || '/';
}
+function invalidHref(href) {
+ if (false) {}
+}
+
var Router =
/*#__PURE__*/
function () {
@@ -3223,7 +3227,13 @@ function () {
var _url_1$parse = url_1.parse(url, true),
pathname = _url_1$parse.pathname,
- query = _url_1$parse.query; // If asked to change the current URL we should reload the current page
+ query = _url_1$parse.query,
+ protocol = _url_1$parse.protocol;
+
+ if (!pathname || protocol) {
+ invalidHref(url);
+ return resolve(false);
+ } // If asked to change the current URL we should reload the current page
// (not location.reload() but reload getInitialProps and other Next.js stuffs)
// We also need to set the method = replaceState always
// as this should not go into the history (That's how browsers work)
@@ -3492,12 +3502,17 @@ function () {
var _this4 = this;
return new _promise["default"](function (resolve, reject) {
- // Prefetch is not supported in development mode because it would trigger on-demand-entries
- if (false) {}
-
var _url_1$parse3 = url_1.parse(url),
- pathname = _url_1$parse3.pathname; // @ts-ignore pathname is always defined
+ pathname = _url_1$parse3.pathname,
+ protocol = _url_1$parse3.protocol;
+
+ if (!pathname || protocol) {
+ invalidHref(url);
+ return;
+ } // Prefetch is not supported in development mode because it would trigger on-demand-entries
+
+ if (false) {} // @ts-ignore pathname is always defined
var route = toRoute(pathname);
Diff for main.js
@@ -1,4 +1,4 @@
-(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[2],{
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[8],{
/***/ "+iuc":
/***/ (function(module, exports, __webpack_require__) {
Co-Authored-By: Joe Haddad <timer150@gmail.com>
Stats from current PRClick to expand stats
|
zeit/next.js canary | ijjk/next.js invalid-href-warning | Change | |
---|---|---|---|
Build Duration | 12.9s | 12.9s | |
node_modules Size |
43.6 MB | 43.6 MB | |
Total Bundle (main, webpack, commons) Size | 206 kB | 206 kB | |
Total Bundle (main, webpack, commons) gzip Size | 67.8 kB | 67.8 kB | |
Client _app Size |
2.39 kB | 2.39 kB | ✓ |
Client _app gzip Size |
1.08 kB | 1.08 kB | ✓ |
Client _error Size |
8.22 kB | 8.22 kB | ✓ |
Client _error gzip Size |
3.16 kB | 3.16 kB | ✓ |
Client pages/index Size |
343 B | 343 B | ✓ |
Client pages/index gzip Size |
246 B | 246 B | ✓ |
Client pages/link Size |
4.08 kB | 4.08 kB | ✓ |
Client pages/link gzip Size |
1.8 kB | 1.8 kB | ✓ |
Client pages/routerDirect Size |
423 B | 423 B | ✓ |
Client pages/routerDirect gzip Size |
306 B | 306 B | ✓ |
Client pages/withRouter Size |
435 B | 435 B | ✓ |
Client pages/withRouter gzip Size |
301 B | 301 B | ✓ |
Client main Size |
15.4 kB | 15.4 kB | ✓ |
Client main gzip Size |
5.35 kB | 5.35 kB | ✓ |
Client commons Size |
188 kB | 188 kB | |
Client commons gzip Size |
61.1 kB | 61.1 kB | |
Client webpack Size |
1.53 kB | 1.53 kB | ✓ |
Client webpack gzip Size |
778 B | 778 B | ✓ |
Base Rendered Size | 1.35 kB | 1.35 kB | ✓ |
Build Dir Size | 702 kB | 703 kB |
Click to expand serverless stats ⚠️ Total Bundle Size Increase ⚠️
zeit/next.js canary | ijjk/next.js invalid-href-warning | Change | |
---|---|---|---|
Build Duration | 14.1s | 14.2s | |
node_modules Size |
43.6 MB | 43.6 MB | |
Total Bundle (main, webpack, commons) Size | 206 kB | 206 kB | |
Total Bundle (main, webpack, commons) gzip Size | 67.8 kB | 67.8 kB | |
Client _app Size |
2.39 kB | 2.39 kB | ✓ |
Client _app gzip Size |
1.08 kB | 1.08 kB | ✓ |
Client _error Size |
8.22 kB | 8.22 kB | ✓ |
Client _error gzip Size |
3.16 kB | 3.16 kB | ✓ |
Client pages/index Size |
343 B | 343 B | ✓ |
Client pages/index gzip Size |
246 B | 246 B | ✓ |
Client pages/link Size |
4.08 kB | 4.08 kB | ✓ |
Client pages/link gzip Size |
1.8 kB | 1.8 kB | ✓ |
Client pages/routerDirect Size |
423 B | 423 B | ✓ |
Client pages/routerDirect gzip Size |
306 B | 306 B | ✓ |
Client pages/withRouter Size |
435 B | 435 B | ✓ |
Client pages/withRouter gzip Size |
301 B | 301 B | ✓ |
Client main Size |
15.4 kB | 15.4 kB | ✓ |
Client main gzip Size |
5.35 kB | 5.35 kB | ✓ |
Client commons Size |
188 kB | 188 kB | |
Client commons gzip Size |
61.1 kB | 61.1 kB | |
Client webpack Size |
1.53 kB | 1.53 kB | ✓ |
Client webpack gzip Size |
778 B | 778 B | ✓ |
Serverless pages/link Size |
251 kB | 251 kB | |
Serverless pages/link gzip Size |
67.8 kB | 67.9 kB | |
Serverless pages/index Size |
244 kB | 244 kB | |
Serverless pages/index gzip Size |
65.6 kB | 65.7 kB | |
Serverless pages/_error Size |
243 kB | 244 kB | |
Serverless pages/_error gzip Size |
65.4 kB | 65.4 kB | |
Serverless pages/routerDirect Size |
244 kB | 245 kB | |
Serverless pages/routerDirect gzip Size |
65.6 kB | 65.6 kB | |
Serverless pages/withRouter Size |
244 kB | 245 kB | |
Serverless pages/withRouter gzip Size |
65.7 kB | 65.8 kB | |
Build Dir Size | 1.89 MB | 1.89 MB |
Diff for commons.js
@@ -3223,7 +3223,14 @@ function () {
var _url_1$parse = url_1.parse(url, true),
pathname = _url_1$parse.pathname,
- query = _url_1$parse.query; // If asked to change the current URL we should reload the current page
+ query = _url_1$parse.query,
+ protocol = _url_1$parse.protocol;
+
+ if (!pathname || protocol) {
+ if (false) {}
+
+ return resolve(false);
+ } // If asked to change the current URL we should reload the current page
// (not location.reload() but reload getInitialProps and other Next.js stuffs)
// We also need to set the method = replaceState always
// as this should not go into the history (That's how browsers work)
@@ -3492,12 +3499,18 @@ function () {
var _this4 = this;
return new _promise["default"](function (resolve, reject) {
- // Prefetch is not supported in development mode because it would trigger on-demand-entries
- if (false) {}
-
var _url_1$parse3 = url_1.parse(url),
- pathname = _url_1$parse3.pathname; // @ts-ignore pathname is always defined
+ pathname = _url_1$parse3.pathname,
+ protocol = _url_1$parse3.protocol;
+
+ if (!pathname || protocol) {
+ if (false) {}
+
+ return;
+ } // Prefetch is not supported in development mode because it would trigger on-demand-entries
+
+ if (false) {} // @ts-ignore pathname is always defined
var route = toRoute(pathname);
Stats from current PRClick to expand stats
|
zeit/next.js canary | ijjk/next.js invalid-href-warning | Change | |
---|---|---|---|
Build Duration | 12.8s | 12.7s | -84ms |
node_modules Size |
43.6 MB | 43.6 MB | |
Total Bundle (main, webpack, commons) Size | 206 kB | 206 kB | |
Total Bundle (main, webpack, commons) gzip Size | 67.8 kB | 67.8 kB | |
Client _app Size |
2.39 kB | 2.39 kB | ✓ |
Client _app gzip Size |
1.08 kB | 1.08 kB | ✓ |
Client _error Size |
8.22 kB | 8.22 kB | ✓ |
Client _error gzip Size |
3.16 kB | 3.16 kB | ✓ |
Client pages/index Size |
343 B | 343 B | ✓ |
Client pages/index gzip Size |
246 B | 246 B | ✓ |
Client pages/link Size |
4.08 kB | 4.08 kB | ✓ |
Client pages/link gzip Size |
1.8 kB | 1.8 kB | ✓ |
Client pages/routerDirect Size |
423 B | 423 B | ✓ |
Client pages/routerDirect gzip Size |
306 B | 306 B | ✓ |
Client pages/withRouter Size |
435 B | 435 B | ✓ |
Client pages/withRouter gzip Size |
301 B | 301 B | ✓ |
Client main Size |
15.4 kB | 15.4 kB | ✓ |
Client main gzip Size |
5.35 kB | 5.35 kB | ✓ |
Client commons Size |
188 kB | 188 kB | |
Client commons gzip Size |
61.1 kB | 61.1 kB | |
Client webpack Size |
1.53 kB | 1.53 kB | ✓ |
Client webpack gzip Size |
778 B | 778 B | ✓ |
Base Rendered Size | 1.35 kB | 1.35 kB | ✓ |
Build Dir Size | 702 kB | 703 kB |
Click to expand serverless stats ⚠️ Total Bundle Size Increase ⚠️
zeit/next.js canary | ijjk/next.js invalid-href-warning | Change | |
---|---|---|---|
Build Duration | 13.8s | 14.3s | |
node_modules Size |
43.6 MB | 43.6 MB | |
Total Bundle (main, webpack, commons) Size | 206 kB | 206 kB | |
Total Bundle (main, webpack, commons) gzip Size | 67.8 kB | 67.8 kB | |
Client _app Size |
2.39 kB | 2.39 kB | ✓ |
Client _app gzip Size |
1.08 kB | 1.08 kB | -1 B |
Client _error Size |
8.22 kB | 8.22 kB | ✓ |
Client _error gzip Size |
3.16 kB | 3.16 kB | ✓ |
Client pages/index Size |
343 B | 343 B | ✓ |
Client pages/index gzip Size |
246 B | 246 B | ✓ |
Client pages/link Size |
4.08 kB | 4.08 kB | ✓ |
Client pages/link gzip Size |
1.8 kB | 1.8 kB | ✓ |
Client pages/routerDirect Size |
423 B | 423 B | ✓ |
Client pages/routerDirect gzip Size |
306 B | 306 B | ✓ |
Client pages/withRouter Size |
435 B | 435 B | ✓ |
Client pages/withRouter gzip Size |
301 B | 300 B | -1 B |
Client main Size |
15.4 kB | 15.4 kB | ✓ |
Client main gzip Size |
5.35 kB | 5.35 kB | ✓ |
Client commons Size |
188 kB | 188 kB | |
Client commons gzip Size |
61.1 kB | 61.1 kB | |
Client webpack Size |
1.53 kB | 1.53 kB | ✓ |
Client webpack gzip Size |
778 B | 778 B | ✓ |
Serverless pages/link Size |
251 kB | 251 kB | |
Serverless pages/link gzip Size |
67.8 kB | 67.9 kB | |
Serverless pages/index Size |
244 kB | 244 kB | |
Serverless pages/index gzip Size |
65.6 kB | 65.7 kB | |
Serverless pages/_error Size |
243 kB | 244 kB | |
Serverless pages/_error gzip Size |
65.4 kB | 65.4 kB | |
Serverless pages/routerDirect Size |
244 kB | 245 kB | |
Serverless pages/routerDirect gzip Size |
65.6 kB | 65.6 kB | |
Serverless pages/withRouter Size |
244 kB | 245 kB | |
Serverless pages/withRouter gzip Size |
65.7 kB | 65.8 kB | |
Build Dir Size | 1.89 MB | 1.89 MB |
Diff for commons.js
@@ -3223,7 +3223,14 @@ function () {
var _url_1$parse = url_1.parse(url, true),
pathname = _url_1$parse.pathname,
- query = _url_1$parse.query; // If asked to change the current URL we should reload the current page
+ query = _url_1$parse.query,
+ protocol = _url_1$parse.protocol;
+
+ if (!pathname || protocol) {
+ if (false) {}
+
+ return resolve(false);
+ } // If asked to change the current URL we should reload the current page
// (not location.reload() but reload getInitialProps and other Next.js stuffs)
// We also need to set the method = replaceState always
// as this should not go into the history (That's how browsers work)
@@ -3492,12 +3499,18 @@ function () {
var _this4 = this;
return new _promise["default"](function (resolve, reject) {
- // Prefetch is not supported in development mode because it would trigger on-demand-entries
- if (false) {}
-
var _url_1$parse3 = url_1.parse(url),
- pathname = _url_1$parse3.pathname; // @ts-ignore pathname is always defined
+ pathname = _url_1$parse3.pathname,
+ protocol = _url_1$parse3.protocol;
+
+ if (!pathname || protocol) {
+ if (false) {}
+
+ return;
+ } // Prefetch is not supported in development mode because it would trigger on-demand-entries
+
+ if (false) {} // @ts-ignore pathname is always defined
var route = toRoute(pathname);
Stats from current PRClick to expand stats
|
zeit/next.js canary | ijjk/next.js invalid-href-warning | Change | |
---|---|---|---|
Build Duration | 22s | 20.9s | -1.1s |
node_modules Size |
43.6 MB | 43.6 MB | |
Total Bundle (main, webpack, commons) Size | 207 kB | 207 kB | |
Total Bundle (main, webpack, commons) gzip Size | 68.1 kB | 68.1 kB | |
Total Bundle (main, webpack, commons) Modern Size | 181 kB | 182 kB | |
Total Bundle (main, webpack, commons) Modern gzip Size | 59.9 kB | 59.9 kB | |
Client _app Size |
2.39 kB | 2.39 kB | ✓ |
Client _app gzip Size |
1.08 kB | 1.08 kB | -1 B |
Client _app Modern Size |
1.83 kB | 1.83 kB | ✓ |
Client _app gzip Modern Size |
890 B | 890 B | ✓ |
Client _error Size |
8.22 kB | 8.22 kB | ✓ |
Client _error gzip Size |
3.16 kB | 3.16 kB | ✓ |
Client _error Modern Size |
5.85 kB | 5.85 kB | ✓ |
Client _error gzip Modern Size |
2.33 kB | 2.33 kB | ✓ |
Client pages/index Size |
343 B | 343 B | ✓ |
Client pages/index gzip Size |
246 B | 246 B | ✓ |
Client pages/index Modern Size |
319 B | 319 B | ✓ |
Client pages/index gzip Modern Size |
254 B | 254 B | ✓ |
Client pages/link Size |
4.08 kB | 4.08 kB | ✓ |
Client pages/link gzip Size |
1.8 kB | 1.8 kB | ✓ |
Client pages/link Modern Size |
3.7 kB | 3.7 kB | ✓ |
Client pages/link gzip Modern Size |
1.7 kB | 1.7 kB | ✓ |
Client pages/routerDirect Size |
423 B | 423 B | ✓ |
Client pages/routerDirect gzip Size |
306 B | 306 B | ✓ |
Client pages/routerDirect Modern Size |
411 B | 411 B | ✓ |
Client pages/routerDirect gzip Modern Size |
314 B | 314 B | ✓ |
Client pages/withRouter Size |
435 B | 435 B | ✓ |
Client pages/withRouter gzip Size |
301 B | 300 B | -1 B |
Client pages/withRouter Modern Size |
423 B | 423 B | ✓ |
Client pages/withRouter gzip Modern Size |
309 B | 309 B | ✓ |
Client main Size |
15.8 kB | 15.8 kB | ✓ |
Client main gzip Size |
5.46 kB | 5.46 kB | |
Client main Modern Size |
12.8 kB | 12.8 kB | ✓ |
Client main Modern gzip Size |
4.83 kB | 4.83 kB | ✓ |
Client commons Size |
188 kB | 188 kB | |
Client commons gzip Size |
61.3 kB | 61.3 kB | |
Client commons Modern Size |
169 kB | 169 kB | |
Client commons Modern gzip Size |
55.1 kB | 55.1 kB | |
Client webpack Size |
1.53 kB | 1.53 kB | ✓ |
Client webpack gzip Size |
778 B | 778 B | ✓ |
Client webpack Modern Size |
1.53 kB | 1.53 kB | ✓ |
Client webpack Modern gzip Size |
785 B | 785 B | ✓ |
Base Rendered Size | 2.76 kB | 2.76 kB | ✓ |
Build Dir Size | 1.39 MB | 1.39 MB |
Click to expand serverless stats ⚠️ Total Bundle Size Increase ⚠️
zeit/next.js canary | ijjk/next.js invalid-href-warning | Change | |
---|---|---|---|
Build Duration | 22.3s | 22.7s | |
node_modules Size |
43.6 MB | 43.6 MB | |
Total Bundle (main, webpack, commons) Size | 207 kB | 207 kB | |
Total Bundle (main, webpack, commons) gzip Size | 68.1 kB | 68.1 kB | |
Total Bundle (main, webpack, commons) Modern Size | 181 kB | 182 kB | |
Total Bundle (main, webpack, commons) Modern gzip Size | 59.9 kB | 59.9 kB | |
Client _app Size |
2.39 kB | 2.39 kB | ✓ |
Client _app gzip Size |
1.08 kB | 1.08 kB | ✓ |
Client _app Modern Size |
1.83 kB | 1.83 kB | ✓ |
Client _app gzip Modern Size |
890 B | 890 B | ✓ |
Client _error Size |
8.22 kB | 8.22 kB | ✓ |
Client _error gzip Size |
3.16 kB | 3.16 kB | ✓ |
Client _error Modern Size |
5.85 kB | 5.85 kB | ✓ |
Client _error gzip Modern Size |
2.33 kB | 2.33 kB | ✓ |
Client pages/index Size |
343 B | 343 B | ✓ |
Client pages/index gzip Size |
246 B | 246 B | ✓ |
Client pages/index Modern Size |
319 B | 319 B | ✓ |
Client pages/index gzip Modern Size |
254 B | 254 B | ✓ |
Client pages/link Size |
4.08 kB | 4.08 kB | ✓ |
Client pages/link gzip Size |
1.8 kB | 1.8 kB | ✓ |
Client pages/link Modern Size |
3.7 kB | 3.7 kB | ✓ |
Client pages/link gzip Modern Size |
1.7 kB | 1.7 kB | ✓ |
Client pages/routerDirect Size |
423 B | 423 B | ✓ |
Client pages/routerDirect gzip Size |
306 B | 306 B | ✓ |
Client pages/routerDirect Modern Size |
411 B | 411 B | ✓ |
Client pages/routerDirect gzip Modern Size |
314 B | 314 B | ✓ |
Client pages/withRouter Size |
435 B | 435 B | ✓ |
Client pages/withRouter gzip Size |
301 B | 301 B | ✓ |
Client pages/withRouter Modern Size |
423 B | 423 B | ✓ |
Client pages/withRouter gzip Modern Size |
309 B | 309 B | ✓ |
Client main Size |
15.8 kB | 15.8 kB | ✓ |
Client main gzip Size |
5.46 kB | 5.46 kB | ✓ |
Client main Modern Size |
12.8 kB | 12.8 kB | ✓ |
Client main Modern gzip Size |
4.83 kB | 4.83 kB | ✓ |
Client commons Size |
188 kB | 188 kB | |
Client commons gzip Size |
61.3 kB | 61.3 kB | |
Client commons Modern Size |
169 kB | 169 kB | |
Client commons Modern gzip Size |
55.1 kB | 55.1 kB | |
Client webpack Size |
1.53 kB | 1.53 kB | ✓ |
Client webpack gzip Size |
778 B | 778 B | ✓ |
Client webpack Modern Size |
1.53 kB | 1.53 kB | ✓ |
Client webpack Modern gzip Size |
785 B | 785 B | ✓ |
Serverless pages/link Size |
255 kB | 255 kB | |
Serverless pages/link gzip Size |
68.5 kB | 68.6 kB | |
Serverless pages/index Size |
247 kB | 248 kB | |
Serverless pages/index gzip Size |
66.3 kB | 66.4 kB | |
Serverless pages/_error Size |
247 kB | 247 kB | |
Serverless pages/_error gzip Size |
66.1 kB | 66.1 kB | |
Serverless pages/routerDirect Size |
248 kB | 248 kB | |
Serverless pages/routerDirect gzip Size |
66.3 kB | 66.3 kB | |
Serverless pages/withRouter Size |
248 kB | 248 kB | |
Serverless pages/withRouter gzip Size |
66.4 kB | 66.4 kB | |
Build Dir Size | 2.59 MB | 2.59 MB |
Diff for commons.js
@@ -3223,7 +3223,14 @@ function () {
var _url_1$parse = url_1.parse(url, true),
pathname = _url_1$parse.pathname,
- query = _url_1$parse.query; // If asked to change the current URL we should reload the current page
+ query = _url_1$parse.query,
+ protocol = _url_1$parse.protocol;
+
+ if (!pathname || protocol) {
+ if (false) {}
+
+ return resolve(false);
+ } // If asked to change the current URL we should reload the current page
// (not location.reload() but reload getInitialProps and other Next.js stuffs)
// We also need to set the method = replaceState always
// as this should not go into the history (That's how browsers work)
@@ -3492,12 +3499,18 @@ function () {
var _this4 = this;
return new _promise["default"](function (resolve, reject) {
- // Prefetch is not supported in development mode because it would trigger on-demand-entries
- if (false) {}
-
var _url_1$parse3 = url_1.parse(url),
- pathname = _url_1$parse3.pathname; // @ts-ignore pathname is always defined
+ pathname = _url_1$parse3.pathname,
+ protocol = _url_1$parse3.protocol;
+
+ if (!pathname || protocol) {
+ if (false) {}
+
+ return;
+ } // Prefetch is not supported in development mode because it would trigger on-demand-entries
+
+ if (false) {} // @ts-ignore pathname is always defined
var route = toRoute(pathname);
Diff for commonsModern.js
@@ -2700,13 +2700,21 @@ class Router {
const {
pathname,
- query
- } = url_1.parse(url, true); // If asked to change the current URL we should reload the current page
+ query,
+ protocol
+ } = url_1.parse(url, true);
+
+ if (!pathname || protocol) {
+ if (false) {}
+
+ return resolve(false);
+ } // If asked to change the current URL we should reload the current page
// (not location.reload() but reload getInitialProps and other Next.js stuffs)
// We also need to set the method = replaceState always
// as this should not go into the history (That's how browsers work)
// We should compare the new asPath to the current asPath, not the url
+
if (!this.urlIsNew(as)) {
method = 'replaceState';
} // @ts-ignore pathname is always a string
@@ -2945,11 +2953,19 @@ class Router {
prefetch(url) {
return new _promise.default((resolve, reject) => {
- // Prefetch is not supported in development mode because it would trigger on-demand-entries
- if (false) {}
const {
- pathname
- } = url_1.parse(url); // @ts-ignore pathname is always defined
+ pathname,
+ protocol
+ } = url_1.parse(url);
+
+ if (!pathname || protocol) {
+ if (false) {}
+
+ return;
+ } // Prefetch is not supported in development mode because it would trigger on-demand-entries
+
+
+ if (false) {} // @ts-ignore pathname is always defined
const route = toRoute(pathname);
this.pageLoader.prefetch(route).then(resolve, reject);
const { pathname, query } = parse(url, true) | ||
const { pathname, query, protocol } = parse(url, true) | ||
|
||
if (!pathname || protocol) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this condition looks wrong, IMO should be !pathname || !protocol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, just stumbled upon this today using Router.push
and passing an absolute URL object to both href
, and as
.
If a user passes a href with
mailto:
or an external linkhttps://google.com
it can cause unexpected behavior.This throws an error in development mode so the invalid
href
can be corrected and handles it gracefully in production.Closes: #8212
Closes: #8273
x-ref: #7843