Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
65bfd163
Commit
65bfd163
authored
Mar 07, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #2646: Added support for specifying hostinfo in the pattern of a URL rule
parent
6d3e60f9
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
0 deletions
+31
-0
CHANGELOG.md
framework/CHANGELOG.md
+1
-0
UrlRule.php
framework/web/UrlRule.php
+6
-0
UrlRuleTest.php
tests/unit/framework/web/UrlRuleTest.php
+24
-0
No files found.
framework/CHANGELOG.md
View file @
65bfd163
...
@@ -134,6 +134,7 @@ Yii Framework 2 Change Log
...
@@ -134,6 +134,7 @@ Yii Framework 2 Change Log
-
Enh #2499: Added ability to downgrade migrations by their absolute apply time (resurtm, gorcer)
-
Enh #2499: Added ability to downgrade migrations by their absolute apply time (resurtm, gorcer)
-
Enh #2525: Added support for formatting file sizes with
`yii\base\Formatter`
(VinceG)
-
Enh #2525: Added support for formatting file sizes with
`yii\base\Formatter`
(VinceG)
-
Enh #2526: Allow for null values in batchInsert (skotos)
-
Enh #2526: Allow for null values in batchInsert (skotos)
-
Enh #2646: Added support for specifying hostinfo in the pattern of a URL rule (qiangxue)
-
Enh: Added support for using arrays as option values for console commands (qiangxue)
-
Enh: Added support for using arrays as option values for console commands (qiangxue)
-
Enh: Added
`favicon.ico`
and
`robots.txt`
to default application templates (samdark)
-
Enh: Added
`favicon.ico`
and
`robots.txt`
to default application templates (samdark)
-
Enh: Added
`Widget::autoIdPrefix`
to support prefixing automatically generated widget IDs (qiangxue)
-
Enh: Added
`Widget::autoIdPrefix`
to support prefixing automatically generated widget IDs (qiangxue)
...
...
framework/web/UrlRule.php
View file @
65bfd163
...
@@ -134,6 +134,12 @@ class UrlRule extends Object implements UrlRuleInterface
...
@@ -134,6 +134,12 @@ class UrlRule extends Object implements UrlRuleInterface
$this
->
_template
=
''
;
$this
->
_template
=
''
;
$this
->
pattern
=
'#^$#u'
;
$this
->
pattern
=
'#^$#u'
;
return
;
return
;
}
elseif
((
$pos
=
strpos
(
$this
->
pattern
,
'://'
))
!==
false
)
{
if
((
$pos2
=
strpos
(
$this
->
pattern
,
'/'
,
$pos
+
3
))
!==
false
)
{
$this
->
host
=
substr
(
$this
->
pattern
,
0
,
$pos2
);
}
else
{
$this
->
host
=
$this
->
pattern
;
}
}
else
{
}
else
{
$this
->
pattern
=
'/'
.
$this
->
pattern
.
'/'
;
$this
->
pattern
=
'/'
.
$this
->
pattern
.
'/'
;
}
}
...
...
tests/unit/framework/web/UrlRuleTest.php
View file @
65bfd163
...
@@ -350,6 +350,18 @@ class UrlRuleTest extends TestCase
...
@@ -350,6 +350,18 @@ class UrlRuleTest extends TestCase
[
'post/index'
,
[
'page'
=>
1
,
'tag'
=>
'a'
,
'lang'
=>
'en'
],
'http://en.example.com/post/a'
],
[
'post/index'
,
[
'page'
=>
1
,
'tag'
=>
'a'
,
'lang'
=>
'en'
],
'http://en.example.com/post/a'
],
],
],
],
],
[
'with host info in pattern'
,
[
'pattern'
=>
'http://<lang:en|fr>.example.com/post/<page:\d+>/<tag>'
,
'route'
=>
'post/index'
,
'defaults'
=>
[
'page'
=>
1
],
],
[
[
'post/index'
,
[
'page'
=>
1
,
'tag'
=>
'a'
],
false
],
[
'post/index'
,
[
'page'
=>
1
,
'tag'
=>
'a'
,
'lang'
=>
'en'
],
'http://en.example.com/post/a'
],
],
],
];
];
}
}
...
@@ -659,6 +671,18 @@ class UrlRuleTest extends TestCase
...
@@ -659,6 +671,18 @@ class UrlRuleTest extends TestCase
[
'post/1/a'
,
false
],
[
'post/1/a'
,
false
],
],
],
],
],
[
'with host info in pattern'
,
[
'pattern'
=>
'http://<lang:en|fr>.example.com/post/<page:\d+>'
,
'route'
=>
'post/index'
,
],
[
[
'post/1'
,
'post/index'
,
[
'page'
=>
'1'
,
'lang'
=>
'en'
]],
[
'post/a'
,
false
],
[
'post/1/a'
,
false
],
],
],
];
];
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment