Skip to content

Commit 15167b4

Browse files
authored
PD-5749 Fix ext ids display on activities (#2869)
* PD-5749 Fix ext ids display on activities * PD-5749 run lin
1 parent d54f378 commit 15167b4

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

src/assets/print-view/fetch-orcid.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -441,9 +441,10 @@ function otherIdsTextNode(label, value, url) {
441441
wrapper.appendChild(prefix)
442442
}
443443

444+
const safeUrl = sanitizeUrl(url)
444445
const valueAsUrl = sanitizeUrl(value)
445-
if (valueAsUrl) {
446-
// If the value itself is a URL, render it as a link and ignore the `url` parameter
446+
if (safeUrl && valueAsUrl) {
447+
// If both are provided and value is a URL, render value as the link
447448
wrapper.appendChild(document.createTextNode(' ('))
448449
const a = document.createElement('a')
449450
a.href = valueAsUrl
@@ -453,10 +454,10 @@ function otherIdsTextNode(label, value, url) {
453454
wrapper.appendChild(a)
454455
wrapper.appendChild(document.createTextNode(')'))
455456
} else {
456-
// Otherwise, keep the existing behavior: render value as text,
457+
// Otherwise, render value as text,
458+
if (value) wrapper.appendChild(document.createTextNode(value))
459+
457460
// and optionally append a (url) link if provided and safe
458-
wrapper.appendChild(document.createTextNode(value))
459-
const safeUrl = sanitizeUrl(url)
460461
if (safeUrl) {
461462
wrapper.appendChild(document.createTextNode(' ('))
462463
const a = document.createElement('a')
@@ -570,9 +571,7 @@ function composeActivityEntryFromJson(entry, opts = {}) {
570571
idRel && idRel.toLowerCase() !== 'self'
571572
? `${localizedRel} ${idType}`.trim()
572573
: idType || STRINGS.identifier
573-
wrapper.appendChild(
574-
otherIdsTextNode(label, idValue || idUrl || '', idUrl)
575-
)
574+
wrapper.appendChild(otherIdsTextNode(label, idValue, idUrl))
576575
})
577576
}
578577

0 commit comments

Comments
 (0)