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

Fix linking path #10708

Merged
merged 3 commits into from
Aug 7, 2022
Merged

Fix linking path #10708

merged 3 commits into from
Aug 7, 2022

Conversation

ercote
Copy link
Contributor

@ercote ercote commented Jul 20, 2022

Motivation

At the moment, a linking url without a path (with or without an ending slash) cannot match the linking configuration, as it is ignored.

Consider the following linking configuration:

{
  prefixes: ['https://myapp.com/'],
  config: {
    screens: {
      MyScreen: '',
    },
  },
};

If the received linking url is equal to https://myapp.com/ it won't be matching MyScreen as the empty path is ignore. To be able to match an empty path, we need to change the path validation (see change in useLinking.native.tsx).

The getStateFromPath function is already able to match an empty string. Tests have been added to clearly expose the expected behaviour.

Test plan

Use a deeplink url without a path in your app and match that deeplink in your linking configuration using an empty path.

@github-actions
Copy link

Hey ercote! Thanks for opening your first pull request in this repo. If you haven't already, make sure to read our contribution guidelines.

@netlify
Copy link

netlify bot commented Jul 20, 2022

Deploy Preview for react-navigation-example ready!

Name Link
🔨 Latest commit e7ddaf6
🔍 Latest deploy log https://app.netlify.com/sites/react-navigation-example/deploys/62d82a46ef3ee5000922bab7
😎 Deploy Preview https://deploy-preview-10708--react-navigation-example.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

Copy link
Member

@satya164 satya164 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR

@satya164 satya164 merged commit e8c374e into react-navigation:main Aug 7, 2022
@ercote ercote deleted the fix-linking-path branch August 9, 2022 05:55
@intergalacticspacehighway

@satya164 @ercote this change resets the navigation state if the app is redirected from another app.

IMO root URL ("" or /) deeplink should be handled when app is opened first time, if it's already opened then it should not reset the navigation state. I can do a PR. Let me know if this is expected.

You can check the below video to see the usecase. Navigation resets on redirection from another app.

RPReplay_Final1664352656.MP4

@github-actions
Copy link

Hey! This issue is closed and isn't watched by the core team. You are welcome to discuss the issue with others in this thread, but if you think this issue is still valid and needs to be tracked, please open a new issue with a repro.

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

Successfully merging this pull request may close these issues.

3 participants