Fix slug routing for Notion pages with username-prefixed paths#61
Merged
Fix slug routing for Notion pages with username-prefixed paths#61
Conversation
Use regex to extract 32-char hex page IDs instead of slice(-32),
which fails when Notion returns paths like /username/Page-Name-{pageId}.
Fixes #55
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/philipb/Ressources-9a8ace54b67c4611b93ead8db1b67c19)pathname.slice(-32)with regex/[0-9a-f]{32}/in 3 locations: client-sidegetPage(),pushStatehook, and server-side canonical URL extractionRoot Cause
When Notion uses a personal workspace, page URLs contain a username prefix:
/{username}/{Page-Name}-{pageId}. The previousslice(-32)approach extracted the last 32 characters of the full path, which included part of the page name instead of just the hex page ID. This causedupdateSlug()to fail, leaving the URL in its raw Notion format.Fix
Using
pathname.match(/[0-9a-f]{32}/)correctly extracts the 32-character hex page ID regardless of the URL path structure.Fixes #55
Test plan
/{pageId})/{username}/{PageName}-{pageId})🤖 Generated with Claude Code