-
-
Notifications
You must be signed in to change notification settings - Fork 67
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
Issue 451 - hanlde headings containg umlauts #452
Conversation
📝 WalkthroughWalkthroughThe change updates the Changes
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
resources/js/Components/Modifications/sticky.js (1)
62-62
: Add error handling for malformed URLs.While the use of
decodeURIComponent
is correct for handling umlauts, it can throw errors for malformed URLs containing invalid percent-encoding.Consider wrapping it in a try-catch:
- hash = decodeURIComponent( window.location.hash.replace( '#', '' ) ), + hash = '', + rawHash = window.location.hash.replace( '#', '' ); + try { + hash = decodeURIComponent( rawHash ); + } catch (e) { + // Fallback to raw hash if decoding fails + hash = rawHash; + mw.log.warn('Failed to decode URL hash:', e); + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
resources/js/Components/Modifications/sticky.js
(1 hunks)
🔇 Additional comments (1)
resources/js/Components/Modifications/sticky.js (1)
59-72
:❓ Verification inconclusive
LGTM! The fix correctly handles umlauts in hash links.
The implementation properly decodes URL-encoded characters, ensuring that links to headings with umlauts work as expected.
Let's verify the fix works with various special characters:
🏁 Script executed:
#!/bin/bash # Description: Test the fix with various special characters by checking for any existing headings with umlauts # Search for heading elements with umlauts or other special characters rg -l '[äöüßÄÖÜ]' | grep -i '\.html?$'Length of output: 40
LGTM! The fix in
resources/js/Components/Modifications/sticky.js
(lines 59–72) correctly decodes URL-encoded characters, ensuring that hash links with special characters such as umlauts work as expected.However, the automated search for headings containing umlauts using the provided shell script did not produce any output. Please manually verify that your HTML files include elements with umlauts (or other special characters) that are intended to be targeted by this functionality.
This PR is related to the issue #451.
This PR contains:
decodeURIComponent()
used insideadjustScroll()
to handle hash with umlauts and other special charactersSummary by CodeRabbit