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

use generics instead of any

convert URLs to https:// instead of unsecure http://
parent 8b0a6bc4
No related branches found
No related tags found
1 merge request!134Refactor
...@@ -664,15 +664,15 @@ export function createNetworkDarkFibreDataLookUp<Datatype extends NrenAndYearDat ...@@ -664,15 +664,15 @@ export function createNetworkDarkFibreDataLookUp<Datatype extends NrenAndYearDat
}; };
} }
export function getLatestData(data: any[]) { export function getLatestData<T extends NrenAndYearDatapoint>(data: T[]) {
// Get the latest year for each NREN, and return the data for that year // Get the latest year for each NREN, and return the data for that year
// Mainly used for URL data, which doesn't make sense to compare across years // Mainly used for URL data, which doesn't make sense to compare across years
const latestData = new Map<string, any>(); const latestData = new Map();
data.forEach(institution => { data.forEach(datapoint => {
const existingData = latestData.get(institution.nren); const existingData = latestData.get(datapoint.nren);
if (!existingData || existingData.year < institution.year) { if (!existingData || existingData.year < datapoint.year) {
latestData.set(institution.nren, institution); latestData.set(datapoint.nren, datapoint);
} }
}); });
return Array.from(latestData.values()); return Array.from(latestData.values());
...@@ -681,7 +681,7 @@ export function getLatestData(data: any[]) { ...@@ -681,7 +681,7 @@ export function getLatestData(data: any[]) {
export function addHttpIfMissing(url: string) { export function 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) // 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]+:\/\//)) { if (!url.match(/^[a-zA-Z]+:\/\//)) {
return 'http://' + url; return 'https://' + url;
} }
return url; return url;
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment