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

CMP-7142: Encode and decode URL fragments for web navigation routing. #1738

Merged
merged 1 commit into from
Dec 16, 2024

Conversation

terrakok
Copy link
Member

This update ensures URL fragments are properly encoded and decoded using encodeURIComponent and decodeURIComponent. It improves handling of special characters in navigation paths, preventing potential issues with URL interpretation. Relevant tests have been updated to reflect this change.

Fixes https://youtrack.jetbrains.com/issue/CMP-7142

Testing

  • Unit tests

Release Notes

Fixes - Navigation

  • Fixed browser navigation integration when route paths contain special symbols

This update ensures URL fragments are properly encoded and decoded using `encodeURIComponent` and `decodeURIComponent`. It improves handling of special characters in navigation paths, preventing potential issues with URL interpretation. Relevant tests have been updated to reflect this change.
@terrakok terrakok requested a review from Schahen December 16, 2024 12:49

private fun NavController.tryToNavigateToUrlFragment(localWindow: BrowserWindow) {
val route = localWindow.location.hash.substringAfter('#', "")
val route = decodeURIComponent(localWindow.location.hash.substringAfter('#', ""))
Copy link
Collaborator

Choose a reason for hiding this comment

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

in theory if in all browsers hash is returned with # we can just remove first symbol but not a big deal

Copy link
Member Author

Choose a reason for hiding this comment

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

why? I don't see benefits here. It is not faster

Copy link
Collaborator

@Schahen Schahen left a comment

Choose a reason for hiding this comment

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

Works like charm!

Thanks!

@terrakok terrakok merged commit 326fea0 into jb-main Dec 16, 2024
7 checks passed
@terrakok terrakok deleted the k.tskh/CMP-7142 branch December 16, 2024 13:25
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.

2 participants