-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Drilldowns] Simpler url parsing in sub url hooks #61245
[Drilldowns] Simpler url parsing in sub url hooks #61245
Conversation
don’t use url.parse to extract hash
@elasticmachine merge upstream |
*/ | ||
|
||
export function areDecodedHashesEqual(urlA: string, urlB: string): boolean { | ||
const getHash = (url: string) => url.split('#')[1] ?? ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the change in a nutshell. instead of using url.parse(url).hash
use this simpler method.
The problem with url.parse that it encodes '
-> %27
.
This test would fail with original functionality: https://github.com/elastic/kibana/pull/61245/files#diff-58b12ddd89613d7380892977f494f217R47
Pinging @elastic/kibana-app-arch (Team:AppArch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with added test
…rl-parsing-in-sub-url-hooks
…:Dosant/kibana into dev/simpler-url-parsing-in-sub-url-hooks
@elasticmachine merge upstream |
@elasticmachine merge upstream |
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
* Simpler url parsing in sub url hooks don’t use url.parse to extract hash * review improvements Co-authored-by: Elastic Machine <[email protected]> # Conflicts: # src/legacy/ui/public/chrome/api/sub_url_hooks.js
* Simpler url parsing in sub url hooks don’t use url.parse to extract hash * review improvements Co-authored-by: Elastic Machine <[email protected]> # Conflicts: # src/legacy/ui/public/chrome/api/sub_url_hooks.js
Summary
Part of #61230
Addresses one of the issues when navigating within different dashboards.
The fix is as simple as removing
url.parse
when extracting hash from the url, but I moved the logic into separate function to be able to add a unit test for an edge case I wanted to fix.This is the unit test which is fixed by this pr:
https://github.com/elastic/kibana/pull/61245/files#diff-58b12ddd89613d7380892977f494f217R47
I bumped into it in #60087 when trying to navigate from 1 dashboard to another using core's navigateToApp using:
Internally core is using url.parse which converts
'
->%27
. Performs the navigation. And then angular maps it back causing 2 history records for one navigation.Change to our existing has encoding workarounds logic makes sure angular does it's update with
replace
Testing
I don't know how to test it in current master. The real use case this is needed for will be introduced later in #60087 (comment) and will be covered by functional test