Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not require a .svg extension #1

Open
ckknight opened this issue Dec 12, 2017 · 3 comments
Open

Do not require a .svg extension #1

ckknight opened this issue Dec 12, 2017 · 3 comments

Comments

@ckknight
Copy link

As-is, if the URI does not end in .svg, then it will fallback to react-native's built-in Image 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 via react-native-remote-svg/SvgImage, then it no longer does the automatic resolveAssetSource.

@seekshiva
Copy link
Owner

@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.

@ckknight
Copy link
Author

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.

@jpschw
Copy link

jpschw commented Jan 9, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants