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

[expo] Update Linking.parse to better handle non-expo urls #5179

Open
wants to merge 2 commits into
base: master
from

Conversation

@koenpunt
Copy link
Contributor

commented Aug 4, 2019

Why

When using Linking.parse with a universal link, the path property of the result would include the host of the url;

Linking.parse('https://example.com/my/path?query=param')
// => {
//   path: 'example.com/my/path', 
//   queryParams: { query: 'param' }
// }

How

I've updated the parsing logic to extract more parts of the url (scheme, host, path, and queryParams), and return that from the parse call;

Linking.parse('https://example.com/my/path?query=param')
// => {
//   scheme: 'https',
//   host: 'example.com',
//   path: 'my/path', 
//   queryParams: { query: 'param' }
// }

And this also works for custom url schemes;

Linking.parse('custom:///my/path?query=param')
// => {
//   scheme: 'custom',
//   host: null,
//   path: 'my/path', 
//   queryParams: { query: 'param' }
// }

Test Plan

I've added unit tests for the parse method.

Note: This might be breaking for some apps that have implemented custom parsing of the path property.

@koenpunt koenpunt force-pushed the koenpunt:linking-parse branch 4 times, most recently from 2e83ce7 to 41d638b Aug 4, 2019

@koenpunt koenpunt force-pushed the koenpunt:linking-parse branch from 41d638b to 69bbf65 Aug 4, 2019

@koenpunt koenpunt changed the title Update Linking.parse to better handle non-expo urls [expo] Update Linking.parse to better handle non-expo urls Aug 5, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.