Open ckknight opened 6 years ago
@ckknight It just matches '.svg' anywhere in the string. So if you have a file named 'something.svg.png', it will wrongly get matched as svg and end up using SvgImage.
But I let it match '.svg' anywhere in the string and not just in the end, since this is actually a valid filename: https://example.com/image.svg?color-scheme=material&show-options=true
How do you propose the file type detection to work? I still haven't added supported for data uri yet.
It can't be assumed that I have control over what the remote URL is. I need a way to be able to render a remote URL as though it were .svg
even if that "magic string" is not found in the URL itself.
Ideally, it might be most appropriate to switch based on the response's Content-Type
header, but that might be out-of-scope for this component.
One of the fundamental principles of Javascript is "Don’t modify objects you don’t own". This component should not attempt to augment the Image object provided by React Native but rather be named something like SVGImage instead.
As-is, if the URI does not end in
.svg
, then it will fallback to react-native's built-inImage
implementation.(See https://github.com/seekshiva/react-native-remote-svg/blob/master/index.js#L8)
I personally would rather handle that fallback case in my own code and only use the
SvgImage
, but if I were to reach in viareact-native-remote-svg/SvgImage
, then it no longer does the automaticresolveAssetSource
.