From 32898cc09f1924ffcf284f4190b1c39d2056f8f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D7=90=D7=95=D7=A4=D7=99=D7=A8=20=D7=A1=D7=91=D7=92-=D7=91?= =?UTF-8?q?=D7=98=D7=90=D7=98?= Date: Tue, 1 Dec 2026 00:44:06 +0000 Subject: [PATCH] fix(isLatLong): reject extra comma-separated segments Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- src/lib/isLatLong.js | 1 + test/validators.test.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/lib/isLatLong.js b/src/lib/isLatLong.js index c4e622753..414a03cd2 100644 --- a/src/lib/isLatLong.js +++ b/src/lib/isLatLong.js @@ -18,6 +18,7 @@ export default function isLatLong(str, options) { if (!includes(str, ',')) return false; const pair = str.split(','); + if (pair.length !== 2) return false; if ((pair[0].startsWith('(') && !pair[1].endsWith(')')) || (pair[1].endsWith(')') && !pair[0].startsWith('('))) return false; diff --git a/test/validators.test.js b/test/validators.test.js index 98d2a12ff..fc4c35d07 100644 --- a/test/validators.test.js +++ b/test/validators.test.js @@ -12828,6 +12828,8 @@ describe('Validators', () => { '(,)', ',', ' ', + '0,0,0', + '10,10,unexpected', ], }); @@ -12852,6 +12854,7 @@ describe('Validators', () => { '40° 89′ 46″ S, 79° 58′ 100″ E', '40° 26.445′ 45″ N, 79° 58′ 55.2″ E', '40° 46″ N, 79° 58′ 56″ W', + '40° 26′ 46″ N, 79° 58′ 56″ W,unexpected', ], }); });