fix(search): refuse empty coordinate components instead of silently dropping them

This commit is contained in:
Rudy Celekli committed 2026-10-12 11:10:42 -04:00
1 parent 8b8ccc9a81
commit fa53eec53d
4 files changed
+21 -2

No files matched your search

@@ -0,0 +1,12 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { parseCoordinateQuery } from './coordinateParser.js';
test('search refuses omitted components and repeated separators', () => {
for (const q of ['30,, -97', ',30,-97', '30,-97,', '30;; -97', '30,; -97'])
assert.equal(parseCoordinateQuery(q), null, q);
for (const q of ['30,-97', '30; -97', '30 -97', 'N 30, W 97'])
assert.deepEqual(
[parseCoordinateQuery(q).lat, parseCoordinateQuery(q).lon],
[30, -97],
);
});