Fix crash with bad location uri (#2746)

fix crash with bad location uri
This commit is contained in:
Ajay Bura
2026-03-09 18:17:15 +11:00
committed by GitHub
parent 503f3c401c
commit 4e4170793e
2 changed files with 17 additions and 7 deletions
+15 -7
View File
@@ -87,13 +87,21 @@ export const scaleYDimension = (x: number, scaledX: number, y: number): number =
};
export const parseGeoUri = (location: string) => {
const [, data] = location.split(':');
const [cords] = data.split(';');
const [latitude, longitude] = cords.split(',');
return {
latitude,
longitude,
};
try {
const [, data] = location.split(':');
const [cords] = data.split(';');
const [latitude, longitude] = cords.split(',');
if (typeof latitude === 'string' && typeof longitude === 'string') {
return {
latitude,
longitude,
};
}
return undefined;
} catch {
return undefined;
}
};
const START_SLASHES_REG = /^\/+/g;