Skip to content

Commit

Permalink
Fix text of markdown links not used on imgproxy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ekzyis committed Oct 3, 2023
1 parent 02c115a commit 19d2f5f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion components/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,16 @@ function ImageOriginal ({ src, topLevel, nofollow, tab, children, onClick, ...pr
)
} else {
// user is not okay with loading original url automatically or there was an error loading the image

// If element parsed by markdown is a raw URL, we use src as the text to not mislead users.
// This will not be the case if [text](url) format is used. Then we will show what was chosen as text.
const isRawURL = /^https?:\/\//.test(children[0])
return (
<a
target='_blank'
rel={`noreferrer ${nofollow ? 'nofollow' : ''} noopener`}
href={src}
>{src}
>{isRawURL ? src : children}
</a>
)
}
Expand Down

0 comments on commit 19d2f5f

Please sign in to comment.