mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
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:
1 parent
82138478d0
commit
3cb30c3f97
16 files changed
+45
-29
No files matched your search
@@ -2,7 +2,7 @@
|
||||
import { computed, shallowRef, useTemplateRef, watch } from 'vue';
|
||||
import { formatDate, t, translateKnown } from '../../../i18n/index.js';
|
||||
import { photoCreator, formatAge } from '../../../layers/wildlifeSightings/photoText.js';
|
||||
import { inatLicenceLabel, inatPhotoUrl, isOpenPhoto } from '../../../layers/wildlifeSightings/records.js';
|
||||
import { ACARTIA_SITE, inatLicenceLabel, inatPhotoUrl, isOpenPhoto } from '../../../layers/wildlifeSightings/records.js';
|
||||
|
||||
const props = defineProps({
|
||||
sighting: { type: Object, required: true },
|
||||
@@ -36,6 +36,8 @@ const age = computed(() => {
|
||||
});
|
||||
const observedDate = computed(() => observedDay.value ? formatDate(Date.parse(`${observedDay.value}T00:00:00Z`), { year: 'numeric', month: 'short', day: 'numeric', timeZone: 'UTC' }) : '');
|
||||
const link = computed(() => {
|
||||
// The "Acartia" label only ever points at the Acartia site, never a row URL.
|
||||
if (acartia.value) return ACARTIA_SITE;
|
||||
try {
|
||||
const url = new URL(props.sighting.link);
|
||||
return url.protocol === 'https:' && !url.username && !url.password ? url.href : null;
|
||||
@@ -89,7 +91,6 @@ watch([() => props.sighting.stableId, () => photo.value?.src], () => { loaded.va
|
||||
</div>
|
||||
</component>
|
||||
<p v-if="acartia || taxa === 'whales'" class="wildlife-sighting-card-guidance">
|
||||
<a v-if="acartia && !/^https:\/\/acartia\.io\/?$/.test(link || '')" href="https://acartia.io" target="_blank" rel="noopener noreferrer">{{ t('Open on Acartia ↗') }}</a>
|
||||
<a href="https://www.bewhalewise.org" target="_blank" rel="noopener noreferrer">{{ t('Be Whale Wise') }}</a>
|
||||
</p>
|
||||
</section>
|
||||
|
||||
@@ -373,6 +373,36 @@ test('missing, restricted, obscured and Acartia photos all use the same compact
|
||||
});
|
||||
});
|
||||
|
||||
test('an Acartia card labels only the Acartia site as Acartia', async (context) => {
|
||||
for (const link of [
|
||||
'https://provider.example/photos/synthetic.jpg',
|
||||
'https://acartia.io.attacker.example/',
|
||||
'https://acartia.io/',
|
||||
])
|
||||
await context.test(link, async (context) => {
|
||||
const f = fixture(context, {
|
||||
...row,
|
||||
origin: 'acartia',
|
||||
stableId: 'acartia:456',
|
||||
provider: { name: 'Synthetic network' },
|
||||
link,
|
||||
});
|
||||
await f.click();
|
||||
const card = f.cardElement();
|
||||
const hrefs = [...card.querySelectorAll('a')].map((a) =>
|
||||
a.getAttribute('href'),
|
||||
);
|
||||
assert.deepEqual(hrefs, [
|
||||
'https://acartia.io/',
|
||||
'https://www.bewhalewise.org',
|
||||
]);
|
||||
assert.equal(
|
||||
card.querySelector('.wildlife-sighting-card-source').textContent,
|
||||
'Acartia ↗',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test('safe placements near each viewport edge exclude actual HUD, toolbar and rail rects', () => {
|
||||
const obstacles = [
|
||||
rect(0, 0, 260, 160),
|
||||
|
||||
Reference in new issue
Block a user