fix(wildlife): point the Acartia card link only at acartia.io

The card's "Acartia" link was built from the contributor-supplied
photo_url, so any https site could appear labelled as Acartia. Acartia
has no documented per-sighting page, so the source link is now always
the Acartia site, on the server projection and again in the card.
The separate "Open on Acartia" fallback link is no longer needed.
This commit is contained in:
Sameh Khamis committed 2026-11-05 16:05:02 -08:00
1 parent 82138478d0
commit 3cb30c3f97
16 files changed
+45 -29

No files matched your search

+4 -13
View File
@@ -247,18 +247,9 @@ export function normalizeInatObservations(
return rows;
}
function acartiaLink(value) {
if (typeof value !== 'string' || value.length > 500)
return 'https://acartia.io';
try {
const url = new URL(value);
return url.protocol === 'https:' && !url.username && !url.password
? url.href
: 'https://acartia.io';
} catch {
return 'https://acartia.io';
}
}
// Acartia has no documented per-sighting page, and photo_url is supplied by the
// contributor. The source link is therefore always the Acartia site itself.
export const ACARTIA_SITE = 'https://acartia.io/';
/** Acartia documents flat rows only. Name and entity are text fields; unknown
* shapes are skipped rather than guessing nested provider data. */
@@ -315,7 +306,7 @@ export function normalizeAcartiaSightings(payload, nowMs) {
cetacean: speciesGroup === 'cetacean',
threatened: false,
provider: { name, entity: cleanText(raw.data_source_entity, 60) },
link: acartiaLink(raw.photo_url),
link: ACARTIA_SITE,
photo: null,
favesCount: 0,
identificationAgreements: 0,
@@ -330,7 +330,7 @@ test('Acartia requires flat provider text, handles trust, and sanitizes type', (
);
});
test('Acartia rejects invalid times/positions and unsafe photo links become the canonical page', () => {
test('Acartia rejects invalid times/positions and its link is always the Acartia site', () => {
for (const overrides of [
{ created: new Date(now - 8 * 24 * hour - 1).toISOString() },
{ created: new Date(now + 10 * 60_000 + 1).toISOString() },
@@ -341,6 +341,10 @@ test('Acartia rejects invalid times/positions and unsafe photo links become the
])
assert.deepEqual(normalizeAcartiaSightings([sighting(overrides)], now), []);
for (const photo_url of [
// A contributor-supplied URL is never labelled as the Acartia source.
'https://provider.example/photo.jpg',
'https://phishing.example/acartia.io/login',
'https://acartia.io.attacker.example/',
'http://provider.example/p.jpg',
'https://user:[email protected]/p.jpg',
'javascript:bad()',
@@ -349,7 +353,7 @@ test('Acartia rejects invalid times/positions and unsafe photo links become the
]) {
assert.equal(
normalizeAcartiaSightings([sighting({ photo_url })], now)[0].link,
'https://acartia.io',
'https://acartia.io/',
);
}
});