Skip to content
Snippets Groups Projects
Commit 90080e8a authored by Bjarke Madsen's avatar Bjarke Madsen
Browse files

Fix relative urls in network map.

parent 901c2a0a
No related branches found
No related tags found
No related merge requests found
......@@ -28,8 +28,13 @@ function NetworkMapUrlPage(): React.ReactElement {
coloredYears
/>
const showYears = [...filterSelection.selectedYears.filter(year => years.has(year))].sort();
const addHttpIfMissing = (url: string) => {
// check if it has a protocol, if not add http (href becomes relative to the current page, so we need to add the protocol to make it work properly)
if (!url.match(/^[a-zA-Z]+:\/\//)) {
return 'http://' + url;
}
return url;
}
return (
<DataPage title="NREN Network Maps"
description="This table provides links to NREN network maps, showing layers 1, 2, and 3 of their networks."
......@@ -57,7 +62,7 @@ function NetworkMapUrlPage(): React.ReactElement {
{yearMap.urls && yearMap.urls.map((url, index) => (
<li key={index}>
{url && (
<a href={url} target="_blank" rel="noopener noreferrer"
<a href={addHttpIfMissing(url)} target="_blank" rel="noopener noreferrer"
style={{ textDecoration: 'none' }}>
{url}
</a>
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment