Skip to content

Commit 95a1606

Browse files
authored
Merge pull request #1068 from lumapps/chore/fix-demos-site-link
chore(demo-site): fix relative link path formatting
2 parents 11988a5 + c1601cf commit 95a1606

File tree

1 file changed

+3
-4
lines changed
  • packages/site-demo/src/components/base

1 file changed

+3
-4
lines changed

packages/site-demo/src/components/base/Link.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@ interface Props {
99

1010
// Format internal link to have the gatsby prefix and trailing slash
1111
const formatInternalLink = (path: string) => {
12-
// origin is not important here as it's removed at the end.
13-
const origin = 'http://localhost';
14-
const url = new URL(path, origin);
12+
// url relative to current page
13+
const url = new URL(path, window.location.href);
1514
if (!url.pathname.endsWith('/')) {
1615
url.pathname += '/';
1716
}
1817
if (path.startsWith('/')) {
1918
url.pathname = withPrefix(url.pathname);
2019
}
21-
return url.toString().replace(origin, '');
20+
return url.pathname;
2221
};
2322

2423
/**

0 commit comments

Comments
 (0)