codezero-be / laravel-localized-routes

⭐️ A convenient way to set up and use localized routes in a Laravel app.
MIT License
505 stars 46 forks source link

When route has final slash, it will redirect to public/ #45

Closed m-valvano-zakeke closed 2 years ago

m-valvano-zakeke commented 3 years ago

Hi!

When I try to redirect to a localized route with the Route::localizedUrl method, if the URL has a final slash it will redirect to the same URL, but with the public/ prefix.

For example, Route::localizedUrl("products") will redirect to "it/products" but Route::localizedUrl("products/") will redirect to "public/it/products".

I have the last version of the package.

Any idea?

Thanks! Mauro

ivanvermeyen commented 3 years ago

Hello,

That is rather weird. But the localizedUrl method was intended for the current URL and accepts a locale instead of a slug. You probably want this:

// Get specific locales...
// This is most useful if you want to generate a URL to switch language.
$url = route('about', [], true, 'en'); // /en/about
$url = route('about', [], true, 'nl'); // /nl/about

I will see what is going on with that public prefix though...