P
P
Pr00f2014-11-03 09:57:41
Laravel
Pr00f, 2014-11-03 09:57:41

Routing Laravel and Cyrillic?

Good afternoon. Tell me, what needs to be done so that links with Cyrillic are processed in Laravel 4.2?
There is a rule in routes.php:

Route::pattern('userName', '[\d\w]{1,16}');
Route::get('user/{userName}', '[email protected]');

I tried different ways (/u, a-z), but links with Russian names never open.
Really Laravel is not able such elementary things?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
WebSpider, 2014-11-03
@WebSpider

And if pattern is written as .*- does it work?
In general, the Cyrillic alphabet must be encoded throughurlencode

S
Sergey Gladkovskiy, 2014-11-04
@SMGladkovskiy

Laravel knows everything. You just need to make a regexp so that Cyrillic characters are taken into account.
For example:

Route::get('test/{slug}', function($slug = null){
        return 'Hello World, '.$slug;
    })->where('slug', '[^0-9\p{Cyrillic}]+');

And so - dig in the direction of \p{...} modifiers...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question