img src component prop is url encoded #1268
Answered
by
ChristianMurphy
piotrblasiak
asked this question in
Q&A
-
I implemented a custom img component and noticed that the src prop is url encoded, so I need to to decodeURIComponent first before using it to get the original value. Is this on purpose and if so, why? |
Beta Was this translation helpful? Give feedback.
Answered by
ChristianMurphy
Dec 1, 2023
Replies: 1 comment
-
Welcome @piotrblasiak! 👋
It is on purpose, the |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ChristianMurphy
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Welcome @piotrblasiak! 👋
It is on purpose, the
src
attribute is a URL (ref: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#src), and URLs need to be URL encoded.If you need to get the unsafe form of the URL, the
decodeURIComponent
function can be used.