@dennisdigital/polaris-components-link
Advanced tools
Comparing version 1.5.0 to 1.5.1
@@ -6,2 +6,13 @@ # Change Log | ||
## [1.5.1](https://github.com/dennisinteractive/polaris-componentlibrary/compare/@dennisdigital/polaris-components-link@1.5.0...@dennisdigital/polaris-components-link@1.5.1) (2020-06-05) | ||
### Bug Fixes | ||
* **Link:** Treat absolute internal links with different subdomain as internal ([8182578](https://github.com/dennisinteractive/polaris-componentlibrary/commit/8182578)) | ||
# [1.5.0](https://github.com/dennisinteractive/polaris-componentlibrary/compare/@dennisdigital/polaris-components-link@1.4.2...@dennisdigital/polaris-components-link@1.5.0) (2020-06-01) | ||
@@ -8,0 +19,0 @@ |
25
Link.js
@@ -64,6 +64,8 @@ /** | ||
// URLs with same domain but different subdomain | ||
// @TODO The condition needs to be improved in the way that it always know what is main domain of the site | ||
if (!ssr && (parseUrl(href).hostname.includes(window.location.hostname))) { | ||
return true; | ||
// absolute URLs with same domain but different subdomains | ||
if (!ssr) { | ||
const siteDomain = window.location.hostname.replace('www.', ''); | ||
if (parseUrl(href).hostname && parseUrl(href).hostname.includes(siteDomain)) { | ||
return true; | ||
} | ||
} | ||
@@ -186,5 +188,16 @@ | ||
target, | ||
to: parseUrl(href) || href, | ||
}; | ||
// internal absolute URLs with different subdomains | ||
if ((!ssr && (parseUrl(href).hostname !== window.location.hostname))) { | ||
return ( | ||
<a | ||
{...linkProps} | ||
href={href} | ||
> | ||
{children} | ||
</a> | ||
); | ||
} | ||
if (parseUrl(href) && parseUrl(href).hash !== null) { | ||
@@ -194,2 +207,3 @@ return ( | ||
{...linkProps} | ||
to={parseUrl(href) || href} | ||
smooth | ||
@@ -205,2 +219,3 @@ > | ||
{...linkProps} | ||
to={parseUrl(href) || href} | ||
> | ||
@@ -207,0 +222,0 @@ {children} |
{ | ||
"name": "@dennisdigital/polaris-components-link", | ||
"version": "1.5.0", | ||
"version": "1.5.1", | ||
"main": "index.js", | ||
@@ -29,3 +29,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "c9b37e1c844ab22fb270a45fa10b4d5e456ffc31" | ||
"gitHead": "e1c4e28429e2e1a96b2adcd48f27e93ac5ce06f1" | ||
} |
Sorry, the diff of this file is not supported yet
561
29344