Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions src/assets/print-view/fetch-orcid.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,10 @@ function otherIdsTextNode(label, value, url) {
wrapper.appendChild(prefix)
}

const safeUrl = sanitizeUrl(url)
const valueAsUrl = sanitizeUrl(value)
if (valueAsUrl) {
// If the value itself is a URL, render it as a link and ignore the `url` parameter
if (safeUrl && valueAsUrl) {
// If both are provided and value is a URL, render value as the link
wrapper.appendChild(document.createTextNode(' ('))
const a = document.createElement('a')
a.href = valueAsUrl
Expand All @@ -453,10 +454,10 @@ function otherIdsTextNode(label, value, url) {
wrapper.appendChild(a)
wrapper.appendChild(document.createTextNode(')'))
} else {
// Otherwise, keep the existing behavior: render value as text,
// Otherwise, render value as text,
if (value) wrapper.appendChild(document.createTextNode(value))

// and optionally append a (url) link if provided and safe
wrapper.appendChild(document.createTextNode(value))
const safeUrl = sanitizeUrl(url)
if (safeUrl) {
wrapper.appendChild(document.createTextNode(' ('))
const a = document.createElement('a')
Expand Down Expand Up @@ -570,9 +571,7 @@ function composeActivityEntryFromJson(entry, opts = {}) {
idRel && idRel.toLowerCase() !== 'self'
? `${localizedRel} ${idType}`.trim()
: idType || STRINGS.identifier
wrapper.appendChild(
otherIdsTextNode(label, idValue || idUrl || '', idUrl)
)
wrapper.appendChild(otherIdsTextNode(label, idValue, idUrl))
})
}

Expand Down
Loading