Skip to content

[6.x] Fix CP Nav active state when trailing slashes are enforced#14363

Merged
jasonvarga merged 1 commit into6.xfrom
nav-active-trailing-slashes
Mar 26, 2026
Merged

[6.x] Fix CP Nav active state when trailing slashes are enforced#14363
jasonvarga merged 1 commit into6.xfrom
nav-active-trailing-slashes

Conversation

@duncanmcclean
Copy link
Copy Markdown
Member

This pull request fixes an issue where enforcing trailing slashes would break the CP nav active state and breadcrumbs on nested pages (eg. entry edit page, asset browser).

This was happening because the generateActivePatternForCpUrl() method generates a regex pattern for active state detection, but when trailing slashes are enforced, the $relativeUrl contains a trailing slash, which breaks the regex.

This PR fixes it by stripping trailing slashes from the relative URL before generating the regex pattern.

Note: I couldn't replicate this locally w/ Herd, but I could on a Forge-provisioned server with our recommended Nginx rules.

Fixes #14126

@jasonvarga jasonvarga merged commit 624a56f into 6.x Mar 26, 2026
18 checks passed
@jasonvarga jasonvarga deleted the nav-active-trailing-slashes branch March 26, 2026 16:23
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.

Enforce trailing slashes - breaks CP breadcrumb nav and asset container path

2 participants