getPathInfo with normalizer
kissdry opened this issue · 2 comments
Hello. If I use ulr rule like this:
[
'class' => 'my\project\SomeUrlRule',
]
along with yii\web\UrlNormalizer in config\main.php, then in SomeUrlRule's method parseRequest() I will get two different results when getting $request->getPathInfo():
en/aaa/bbb (before "normalization")
and
aaa/bbb/ (after "normalization")
Would you please advise, how should I handle this situation? I am sure, that it would be totally wrong of me to check urlManager->languages param and try to remove it from the beginning of $request->getPathInfo(). It feels like a very unpleasant issue or am I missing something obvious?
Frankly: I'd try to avoid UrlNormalizer if possible. Dealing with trailing slashes is much better done in the webserver configuration (Apache, Nginx).
When this library was written, there was no UrlNormalizer. IMO its implementation is not very well designed as it makes it very hard to intercept its process. This already gave me big headaches and forced me to write some ugly, hard to follow code like this:
https://github.com/codemix/yii2-localeurls/blob/master/UrlManager.php#L187
I tend to refuse fixing any further bugs related to the UrlNormalizer as it makes maintaining this extension a constant pain.
Closing this as there was no further feedback.