Repository navigation
Conversation
Split application route paths from OAuth callback parameters before parsing to prevent URL encoding of the route portion. This fixes issues where fragments like #/admin/scripts become %2Fadmin%2Fscripts%3D after OAuth callbacks. Co-authored-by: jonkoops <695720+jonkoops@users.noreply.github.com>
Simplify complex boolean expressions for better readability: - Use Math.min with filtered indices to find parameter start - Extract separator logic into clearer variables Co-authored-by: jonkoops <695720+jonkoops@users.noreply.github.com>
Clarify that the second initializeAdapter call processes OAuth callback parameters after redirect. Co-authored-by: jonkoops <695720+jonkoops@users.noreply.github.com>
|
@copilot this is terrible and hacky, I want to use the original URL that is stored in the callback parameters and stored in local storage to find the cut-off point for the parameters for example, if |
Instead of heuristically detecting path-style fragments, use the original redirect URI stored during login to determine where OAuth callback parameters start. This eliminates the hacky approach and properly handles all fragment types by comparing the current callback URL with the stored redirect URI. Co-authored-by: jonkoops <695720+jonkoops@users.noreply.github.com>
Completely rewrote the implementation to use the stored redirect URI from local storage. The solution now:
Commit: cced3ed |
Specify what happens in catch blocks when URL parsing fails. Co-authored-by: jonkoops <695720+jonkoops@users.noreply.github.com>
|
@copilot all the parsing logic should be isolated to |
Move stored redirect URI retrieval into parseCallbackUrl itself, eliminating the two-pass approach. The method now extracts the state parameter internally to retrieve stored callback data and uses it for parsing in a single pass. Co-authored-by: jonkoops <695720+jonkoops@users.noreply.github.com>
Refactored to isolate all parsing logic within Commit: 68cc0b5 |
|
Sigh, this is again terrible code quality. @copilot just make me a new PR with only the failing tests, we'll do the implementation ourselves. |
Combine state extraction and parsing into single conditional blocks to eliminate redundant responseMode checks. Co-authored-by: jonkoops <695720+jonkoops@users.noreply.github.com>
Reverted all implementation changes to lib/keycloak.js. PR now contains only the test cases that demonstrate the URL encoding bug with path-style fragments. Co-authored-by: jonkoops <695720+jonkoops@users.noreply.github.com>
Reverted all implementation changes. PR now contains only the failing tests in Commit: 3685b58 |
|
Going to work on the implementation for this one myself, closing. |
Fragment-based routes (e.g.,
#/admin/maintenance/scripts) are being URL-encoded during OAuth callback parsing, breaking hash-based routing. The route path is treated as a URLSearchParams key, causing#/admin/scriptsto become#%2Fadmin%2Fscripts=.Test Cases
This PR contains only failing tests that demonstrate the bug. Two test cases are included in
test/tests/preserves-path-fragment.spec.ts:#/admin/maintenance/scriptsis preserved without encoding after login#/admin/users?tab=detailsis preserved without encoding after loginExpected Behavior (Currently Failing)
After OAuth redirect, the fragment should be preserved as-is:
#/admin/maintenance/scriptsshould remain#/admin/maintenance/scripts#%2Fadmin%2Fmaintenance%2Fscripts%3DActual Behavior (Bug)
The fragment gets URL-encoded, breaking hash-based routing in single-page applications.
Note: This PR contains only the failing tests to demonstrate the bug. Implementation will be provided separately.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.