Skip to content

A spy satellite simulator in your browser, except the data is real. Live open source spatial intelligence on a photorealistic 3D globe.

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

Rudy Celeklifa53eec53dd8
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b24ac95ed..598588ffa 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,7 @@
# Changelog
+- Coordinate searches refuse empty latitude or longitude components instead of navigating to an unintended location.
+
- Treat explicitly current, complete empty vessel coverage as a successful update,
clearing obsolete contacts while retaining stale or incomplete snapshots.
diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md
index 26d56e66b..b490d308f 100644
--- a/docs/CURRENT-STATE.md
+++ b/docs/CURRENT-STATE.md
@@ -5127,3 +5127,8 @@ datacenters, dams and the Nepal locator retain that shared credit while displaye
Military fragments stitch by source identity. Different mapped parcels merge only
when their footprints touch or contain one another, never across a seam tolerance gap.
+
+
+### fix(search): refuse empty coordinate components instead of silently dropping them
+
+Require exactly two nonempty components while preserving comma, semicolon and whitespace pairs. Malformed separator input falls through to geocoding.
diff --git a/src/search/coordinate-empty-components.test.mjs b/src/search/coordinate-empty-components.test.mjs
new file mode 100644
index 000000000..48bca54ed
--- /dev/null
+++ b/src/search/coordinate-empty-components.test.mjs
@@ -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],
+ );
+});
diff --git a/src/search/coordinateParser.js b/src/search/coordinateParser.js
index 261e2394c..cb8c85524 100644
--- a/src/search/coordinateParser.js
+++ b/src/search/coordinateParser.js
@@ -49,8 +49,8 @@ function splitComponents(query) {
const parts = /[,;]/.test(text)
? text.split(/[,;]/)
: text.split(/\s+(?=[+-]?[.\d]|[NSEW]\s*[+-]?[.\d])/i);
- const trimmed = parts.map((part) => part.trim()).filter(Boolean);
- return trimmed.length === 2 ? trimmed : null;
+ const trimmed = parts.map((part) => part.trim());
+ return trimmed.length === 2 && trimmed.every(Boolean) ? trimmed : null;
}
/** Present a parsed pair the way a coordinate is normally written. */