Credits keep their linked words: only the words a source linked are the link

A credit read from markup keeps the first link's own words as linkText, and the Cesium credit display and the credit line link just those words, as the source wrote them (Street Level's "© Mapillary contributors" links Mapillary only). The Street Level gate reads a drawn item's pick id from its draw-set id.
This commit is contained in:
Sameh Khamis committed 2026-11-15 20:12:14 -08:00
1 parent 74673f3c85
commit a7fe3eebc6
9 files changed
+123 -8

No files matched your search

+6 -1
View File
@@ -23,12 +23,13 @@ import {
LOGO_SCHEMES,
creditFromMarkup,
safeUrl,
splitLink,
} from '../creditMarkup.js';
import { provideUnboundCredits } from '../rendererOf.js';
import { listenerList, uncaught } from './common.js';
import { creditDisplayContents } from './internals.js';
const CREDIT_KEYS = new Set(['text', 'href', 'logoUrl', 'inline']);
const CREDIT_KEYS = new Set(['text', 'href', 'linkText', 'logoUrl', 'inline']);
/** Readings kept per Cesium credit id; past this many, the cache restarts. */
const READINGS_KEPT = 512;
@@ -61,6 +62,10 @@ export function creditMarkup(credit) {
.filter(Boolean)
.join(' ');
const href = credit.href && safeUrl(credit.href, LINK_SCHEMES);
if (href && !logo && credit.linkText) {
const [before, words, after] = splitLink(credit);
return `<span>${escape(before)}<a href="${escape(href)}" target="_blank" rel="noopener">${escape(words)}</a>${escape(after)}</span>`;
}
return href
? `<a href="${escape(href)}" target="_blank" rel="noopener">${body}</a>`
: `<span>${body}</span>`;
+11
View File
@@ -94,6 +94,7 @@ test('Cesium’s own credits are listed as plain data, the logo first', () => {
{
text: 'Data © Example & others',
href: 'https://example.com/a',
linkText: 'Example',
inline: false,
},
]);
@@ -422,3 +423,13 @@ test('a Cesium viewer with no renderer gets a credits port over its display', ()
assert.equal(listeners.size, 1);
assert.equal(findCredits({ creditDisplay: display }), null, 'no scene');
});
test('only the linked words are the link in the credit markup', () => {
const html = creditMarkup({
text: 'Street Level: imagery © Mapillary contributors, CC BY-SA 4.0',
href: 'https://www.mapillary.com/',
linkText: 'Mapillary',
});
assert.ok(html.includes('© <a href="https://www.mapillary.com/"'), html);
assert.ok(html.includes('>Mapillary</a> contributors, CC BY-SA 4.0'), html);
});