Skip to content

Commit

Permalink
GroupUrlRule slash in prefix (yiisoft#19330)
Browse files Browse the repository at this point in the history
* Bring back slash

* changelog

* group url rule test
  • Loading branch information
Bizley committed Mar 29, 2022
1 parent 091b055 commit f6d3283
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions framework/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Yii Framework 2 Change Log
- Enh #19304: Add filtering validator `yii\validators\TrimValidator` (WinterSilence)
- Enh #19309: Optimize `yii\base\Model::attributes()` (WinterSilence)
- Bug #19322: Revert force setting value to empty string in case it's `null` in `yii\validators\FilterValidator::validateAttribute()` (bizley)
- Bug #19329: Fix `yii\web\GroupUrlRule` to properly normalize prefix (bizley)


2.0.45 February 11, 2022
Expand Down
2 changes: 1 addition & 1 deletion framework/web/GroupUrlRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class GroupUrlRule extends CompositeUrlRule
*/
public function init()
{
$this->prefix = trim((string)$this->prefix);
$this->prefix = trim((string)$this->prefix, '/');
$this->routePrefix = $this->routePrefix === null ? $this->prefix : trim($this->routePrefix, '/');
parent::init();
}
Expand Down
15 changes: 15 additions & 0 deletions tests/framework/web/GroupUrlRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,21 @@ protected function getTestsForParseRequest()
['create', false],
],
],
[
'slash prefix',
[
'prefix' => '/',
'rules' => [
'login' => 'user/login',
'logout' => 'user/logout',
],
],
[
['login', 'user/login'],
['logout', 'user/logout'],
['create', false],
],
],
[
'prefix only',
[
Expand Down

0 comments on commit f6d3283

Please sign in to comment.