From 393d38cc663907d511cab1b3d41c222d7f3b420e Mon Sep 17 00:00:00 2001 From: skratchdot Date: Fri, 8 Jun 2018 21:16:28 -0400 Subject: [PATCH 1/4] Adding baseUrl to feed links. This fixes a bug reported in jest: https://github.com/facebook/jest/issues/6418 --- lib/core/Head.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/core/Head.js b/lib/core/Head.js index 1334796bef7d..204336434223 100644 --- a/lib/core/Head.js +++ b/lib/core/Head.js @@ -80,7 +80,11 @@ class Head extends React.Component { )} @@ -88,7 +92,11 @@ class Head extends React.Component { )} From b275b1a94916c553c846c86bb8ecf3113f8e0dd2 Mon Sep 17 00:00:00 2001 From: skratchdot Date: Fri, 8 Jun 2018 22:05:19 -0400 Subject: [PATCH 2/4] Ensure the feedBase variable does not end in a slash --- lib/core/Head.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/core/Head.js b/lib/core/Head.js index 204336434223..8324fa463cf7 100644 --- a/lib/core/Head.js +++ b/lib/core/Head.js @@ -29,6 +29,11 @@ class Head extends React.Component { highlight.version }/styles/${highlight.theme}.min.css`; + // ensure the feedBase variable does not end in a slash + const feedBase = ( + this.props.config.url + this.props.config.baseUrl + ).replace(/\/$/, ''); + return ( @@ -80,11 +85,7 @@ class Head extends React.Component { )} @@ -92,11 +93,7 @@ class Head extends React.Component { )} From 7f46dc2ac8299042b400d08251de7e17761c5808 Mon Sep 17 00:00:00 2001 From: skratchdot Date: Sun, 10 Jun 2018 10:51:19 -0400 Subject: [PATCH 3/4] Get more re-use out of the new `siteUrl` variable --- lib/core/Head.js | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/lib/core/Head.js b/lib/core/Head.js index 8324fa463cf7..a62dbbdb469e 100644 --- a/lib/core/Head.js +++ b/lib/core/Head.js @@ -29,10 +29,10 @@ class Head extends React.Component { highlight.version }/styles/${highlight.theme}.min.css`; - // ensure the feedBase variable does not end in a slash - const feedBase = ( - this.props.config.url + this.props.config.baseUrl - ).replace(/\/$/, ''); + // ensure the siteUrl variable ends with a single slash + const siteUrl = + (this.props.config.url + this.props.config.baseUrl).replace(/\/*$/, '') + + '/'; return ( @@ -48,22 +48,14 @@ class Head extends React.Component { {this.props.config.ogImage && ( )} {this.props.config.twitterImage && ( )} {this.props.config.noIndex && } @@ -85,7 +77,7 @@ class Head extends React.Component { )} @@ -93,7 +85,7 @@ class Head extends React.Component { )} From 2505d4ac5dcce08c9cbaa5d8da0ac6a3a698ed54 Mon Sep 17 00:00:00 2001 From: skratchdot Date: Sun, 10 Jun 2018 10:58:14 -0400 Subject: [PATCH 4/4] Slight regex performance tweak --- lib/core/Head.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core/Head.js b/lib/core/Head.js index a62dbbdb469e..a0efbe22c70c 100644 --- a/lib/core/Head.js +++ b/lib/core/Head.js @@ -31,7 +31,7 @@ class Head extends React.Component { // ensure the siteUrl variable ends with a single slash const siteUrl = - (this.props.config.url + this.props.config.baseUrl).replace(/\/*$/, '') + + (this.props.config.url + this.props.config.baseUrl).replace(/\/+$/, '') + '/'; return (