function extractLocations()

in parsers/locations/about-locations-parser.js [17:34]


function extractLocations(headerRow) {
	const headerCells = headerRow.querySelectorAll("th");
	const locations = [];
	for (const cell of headerCells) {
		const text = cell.textContent.trim();
		if(text != "Products") {
			// extract "europe-west1" from "Belgium (europe-west1)    Low CO2"
			const match = text.match(/\((.*)\)/);
			if(match) {
				const region = match[1];
				locations.push(region);
			} else {
				console.error(`Cannot extract region for ${text}`);
			}
		}
	}
	return locations;
}