Yii2: Duplicate slashes if set param 'suffix' of the component UrlManager to '/'

Created on 24 Feb 2017  路  5Comments  路  Source: yiisoft/yii2

What steps will reproduce the problem?

13522

[
    'suffix'     => '/',
    ['pattern' => '<page:\d+>', 'route' => 'site/index', 'defaults' => ['page' => 1]],
]

Then create a URL like that

Url::to(['site/index', 'page' => 1])

What is the expected result?

The generated URL should be

<a href="/">Home</a>

What do you get instead?

<a href="//">Home</a>

Additional info

| Q | A
| ---------------- | ---
| Yii version | 2.0.11.2
| PHP version | 7.0.15
| Operating system | Centos 6

Issue is not reproducible on Yii 2.0.10

bug

All 5 comments

Probably will be fixed by https://github.com/yiisoft/yii2/pull/13624

Is there a typo in the issue description? The URL rule has a site/brand route and the URL creation example - site/index.

If we assume that the URL creation example should have a site/brand route then the expected result is incorrect since the non-optional parameter brand is omitted.

Sorry, for my typo in the description. I corrected it.

Confirmed via #13660.

The problem will be fixed by #13624
Added test to confirm it: https://github.com/yiisoft/yii2/pull/13624/commits/7206b2ba8a9e2a7648fa5507ce338fc851bc0a6e

Was this page helpful?
0 / 5 - 0 ratings