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

Parse URL Parameters Properly #183

Merged

Conversation

jvartanian
Copy link
Contributor

Currently, URL fragments are being treated as a part of the query string. These are two distinct pieces of a URL, and should be handled separately. This PR updates the logic within WebUtils.getUrlParams() to:

  • Parse the urlString using the Javascript URL interface. This interface properly separates the query string and fragment
  • If the URL doesn't contain a query string or a fragment, return undefined
  • If the URL contains a query string, parse its values, otherwise parse the fragment

@jvartanian
Copy link
Contributor Author

This resolves #182

@mikemellor11
Copy link

The example facebook Web flow also currently fails due to the returned response not being parsed correctly.

The Url from the provider/facebook is returned as:

http://localhost:3000/login?#access_token=...

Which then gets parsed as

{
  "#access_token": "..."
}

Which then thows ERR_NO_ACCESS_TOKEN as it doesn't expect to find the hash

@moberwasserlechner moberwasserlechner merged commit dc9ed19 into capacitor-community:main Apr 11, 2023
@moberwasserlechner
Copy link
Collaborator

Thanks for this PR

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

Successfully merging this pull request may close these issues.

3 participants