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

Different behavior from browser URL #368

Closed
wachunei opened this issue Oct 14, 2021 · 3 comments
Closed

Different behavior from browser URL #368

wachunei opened this issue Oct 14, 2021 · 3 comments

Comments

@wachunei
Copy link

wachunei commented Oct 14, 2021

Hello Nicolas, I'm working with IPFS URLS and I noticed the properties are parsed differently than the URL implementation present on the browsers: https://snack.expo.dev/ar0b1IBPg

Is this a bug? I would like to rely on this library to separate the protocol from the rest of the URL in order to replace it with a gateway, what would you recommend to do?


Properties of ipfs://QmXnnyufdzAWL5CqZ2RnSNgPbvCc1ALT73s6epPrRnZ1Xy with URL and the polyfill

Screen Shot 2021-10-14 at 11 50 12

@charpeni
Copy link
Owner

👋

I’m not on my computer right now, but I can provide some additional details in the meantime.

The URL implementation provided by default on React Native is buggy and not spec compliant. See the README for more information.

I have more trust in this library!

If we want to compare with browsers implementations, we can look at: https://jsdom.github.io/whatwg-url/#url=aXBmczovL1FtWG5ueXVmZHpBV0w1Q3FaMlJuU05nUGJ2Q2MxQUxUNzNzNmVwUHJSbloxWHk=&base=YWJvdXQ6Ymxhbms=.

Let me know if you have other questions.

@wachunei
Copy link
Author

Thank you very much for your promptly response. Wow, so even Browser implementation is not spec compliant? 🤯 I'll rely on this library then! Closing this.

@charpeni
Copy link
Owner

Well, yes, browser implementations should be fine, the issue relies within React Native because they chose to create a small homemade implementation of URL. So, when you use global URL in React Native, it’s using RN’s polyfill which is buggy and not spec compliant.

More information here: facebook/react-native#30188.

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

2 participants