Skip to content

Commit 1458c43

Browse files
committed
PD-5749 Fix ext ids display on activities
1 parent cf2c57f commit 1458c43

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

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

Lines changed: 8 additions & 6 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,11 @@ 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)
459+
wrapper.appendChild(document.createTextNode(value))
460+
457461
// and optionally append a (url) link if provided and safe
458-
wrapper.appendChild(document.createTextNode(value))
459-
const safeUrl = sanitizeUrl(url)
460462
if (safeUrl) {
461463
wrapper.appendChild(document.createTextNode(' ('))
462464
const a = document.createElement('a')
@@ -571,7 +573,7 @@ function composeActivityEntryFromJson(entry, opts = {}) {
571573
? `${localizedRel} ${idType}`.trim()
572574
: idType || STRINGS.identifier
573575
wrapper.appendChild(
574-
otherIdsTextNode(label, idValue || idUrl || '', idUrl)
576+
otherIdsTextNode(label, idValue, idUrl)
575577
)
576578
})
577579
}

0 commit comments

Comments
 (0)