This PR ensures that there is only ever exactly one slash (/) between a generated URL's origin and path. This fixes an issue where it was possible to end up with a double slash if the very first segment of the path is an optional, omitted, route parameter. For example, {locale?}/foo could generate domain.com//foo if the locale param wasn't provided.
Note: This PR intentionally does not change the behaviour of omitted optional route params inside the route path. It's still possible to get double slashes there, e.g. with something like /foo/{param?}/bar, but this matches the behaviour of Laravel's route() function.
This PR ensures that there is only ever exactly one slash (
/
) between a generated URL's origin and path. This fixes an issue where it was possible to end up with a double slash if the very first segment of the path is an optional, omitted, route parameter. For example,{locale?}/foo
could generatedomain.com//foo
if thelocale
param wasn't provided.Note: This PR intentionally does not change the behaviour of omitted optional route params inside the route path. It's still possible to get double slashes there, e.g. with something like
/foo/{param?}/bar
, but this matches the behaviour of Laravel'sroute()
function.Resolves the issue discussed in #616. See https://github.com/tighten/ziggy/discussions/616#discussioncomment-5620680.