Skip to content

Commit abc0840

Browse files
author
Lalit Sharma
committed
feat: refactor parseGoogleDecimalPairFromText to use matchAll for improved regex matching
1 parent 2992b60 commit abc0840

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

apps/mobile/src/utils/sharedMapLink.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,9 @@ function parseGoogleDecimalPairFromText(input: string): { lat: number; lon: numb
313313
if (!input) return null;
314314

315315
// Scan for decimal pairs with 4+ decimal places
316-
const regex = new RegExp(GOOGLE_DECIMAL_PAIR_RE);
317-
let match = regex.exec(input);
318-
while (match !== null) {
316+
// Use matchAll to properly iterate with the global flag
317+
const matches = input.matchAll(GOOGLE_DECIMAL_PAIR_RE);
318+
for (const match of matches) {
319319
const groups = match.groups as { lat?: string; lon?: string } | undefined;
320320
if (groups?.lat && groups?.lon) {
321321
const lat = Number(groups.lat);
@@ -330,7 +330,6 @@ function parseGoogleDecimalPairFromText(input: string): { lat: number; lon: numb
330330
return sanitizeCoordinates({ lat, lon });
331331
}
332332
}
333-
match = regex.exec(input);
334333
}
335334

336335
return null;

0 commit comments

Comments
 (0)