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

Fix route().current() with wheres including regex start/end anchors #535

Merged
merged 2 commits into from
Mar 25, 2022

Conversation

bakerkretzmar
Copy link
Collaborator

This PR updates Ziggy to strip any leading/trailing ^ and $ regex anchor tokens from route parameter 'where' constraints before attempting to compile a route pattern. Previously, a route with something like ->where('parameter', '^(?!nova-api|nova-vendor)$') would eventually end up with Ziggy's javascript attempting to match something like ziggy.dev/(?<parameter>^(?!nova-api|nova-vendor)$)/path, which would never match anything. Now, it produces ziggy.dev/(?<parameter>(?!nova-api|nova-vendor))/path.

Laravel (via Symfony) already strips these out before it does any route matching, so they're not actually doing anything there (Symfony's Route, which Laravel's Route uses internally when matching). This PR brings Ziggy in line with this behaviour.

Fixes #534.

@bakerkretzmar bakerkretzmar merged commit b507e53 into main Mar 25, 2022
@bakerkretzmar bakerkretzmar deleted the jbk/issue-534-route-current-regression branch March 25, 2022 16:02
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.

regression in javascript : route().current() returns undefined in 1.4.4 for some routes
1 participant