From 826c0e5f4d452b15fd8cfc0f9e5cc4c9ad8f343b Mon Sep 17 00:00:00 2001 From: Vesa Luusua Date: Wed, 17 Oct 2018 13:57:15 +0300 Subject: [PATCH] Page: handle enforced referrer --- src/components/Page/Page.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/Page/Page.js b/src/components/Page/Page.js index 0b033c25..3df6bab0 100644 --- a/src/components/Page/Page.js +++ b/src/components/Page/Page.js @@ -67,6 +67,7 @@ class PageComponent extends Component { location, intl, scrollingDisabled, + referrer, author, contentType, description, @@ -84,8 +85,11 @@ class PageComponent extends Component { [css.scrollingDisabled]: scrollingDisabled, }); + const referrerMeta = referrer ? : null; + const canonicalRootURL = config.canonicalRootURL; - const canonicalPath = canonicalRoutePath(routeConfiguration(), location); + const shouldReturnPathOnly = referrer && referrer !== 'unsafe-url'; + const canonicalPath = canonicalRoutePath(routeConfiguration(), location, shouldReturnPathOnly); const canonicalUrl = `${canonicalRootURL}${canonicalPath}`; const siteTitle = config.siteTitle; @@ -186,6 +190,7 @@ class PageComponent extends Component { }} > {title} + {referrerMeta} @@ -219,6 +224,7 @@ PageComponent.defaultProps = { facebookImages: null, twitterImages: null, published: null, + referrer: null, schema: null, tags: null, twitterHandle: null, @@ -231,6 +237,9 @@ PageComponent.propTypes = { children: any, scrollingDisabled: bool.isRequired, + // Handle referrer policy + referrer: string, + // SEO related props author: string, contentType: string, // og:type