-
Notifications
You must be signed in to change notification settings - Fork 241
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
Ziggy generates URL with a double leading slash #751
Comments
What's your actual route path? Is it at the root of your app's domain, so the entire URI is literally I'm adding tests for this to Ziggy and testing it in a real app too and I actually can't reproduce your exact examples. Laravel and Ziggy are behaving the same way for me, but they both behave differently if the route parameter is right at the root of the domain: Route::get('{catalog_uri}', fn() => '')->where('catalog_uri', '^/p/.+$')->name('catalog1');
Route::get('catalog/{catalog_uri}', fn() => '')->where('catalog_uri', '^/p/.+$')->name('catalog2'); Both Laravel and Ziggy produce the same output for these:
|
@bakerkretzmar The catalog routes are bound to a different domain, which is why these routes existing at all, so we can generate them correctly with the alternate domain. Route::domain('catalog.example.com')->group(function () {
Route::get('{catalog_uri}', fn() => view('pdp'))
->where('catalog_uri', '^/p/.+$')
->name('pdp');
}); Does that answer your question? |
Yeah it does, thanks. I can't reproduce this at all then. When I add a route with the exact configuration you shared to Ziggy's tests or to one of my own apps, Ziggy's |
@bakerkretzmar apologies...in my attempt to simply this for the ticket I actually removed the component that causes the issue. You're right that the scenario above works as expected. // catalog.php
Route::domain('{storefront}.example.com')->name('test.')->group(function () {
Route::get('{catalog_uri}', fn() => view('pdp'))
->where('catalog_uri', '^/p/.+$')
->name('pdp');
}); Calling it like this in Vue: <pre>
test pdp: {{
route('catalog.test.pdp', {
storefront: 'me',
catalog_uri: '/p/test',
})
}}
</pre> Yields For context, we run a multi-tenant site with multiple storefronts, each with its own subdomain. |
Thanks, I can reproduce that. Will investigate! |
I'll tag another release for this shortly. Thanks for your help @tmannherz! |
Ziggy version
v2.1.0
Laravel version
v10.48.4
Description
We have a route whose sole parameter comes from the DB:
It's admittedly non-standard as you would usually move
/p/
as part of the route, but this prefix is part of the data provided by the catalog.In Laravel, creating a URL to this route works as you would expect:
Yet if generated by Ziggy, a URL with a double-slash is generated:
Ziggy call and context
Ziggy configuration
Route definition
The text was updated successfully, but these errors were encountered: