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
f31369e7
Commit
f31369e7
authored
Feb 10, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
url wip
parent
712f4dae
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
4 deletions
+11
-4
UrlRule.php
framework/web/UrlRule.php
+10
-2
UrlRuleTest.php
tests/unit/framework/web/UrlRuleTest.php
+1
-2
No files found.
framework/web/UrlRule.php
View file @
f31369e7
...
@@ -112,8 +112,13 @@ class UrlRule extends Object
...
@@ -112,8 +112,13 @@ class UrlRule extends Object
// match the route part first
// match the route part first
if
(
$route
!==
$this
->
route
)
{
if
(
$route
!==
$this
->
route
)
{
if
(
$this
->
routeRule
!==
null
&&
preg_match
(
$this
->
routeRule
,
$route
,
$matches
))
{
if
(
$this
->
routeRule
!==
null
&&
preg_match
(
$this
->
routeRule
,
$route
,
$matches
))
{
foreach
(
$this
->
routeParams
as
$key
=>
$name
)
{
foreach
(
$this
->
routeParams
as
$name
=>
$token
)
{
$tr
[
$name
]
=
$matches
[
$key
];
if
(
isset
(
$this
->
defaults
[
$name
])
&&
strcmp
(
$this
->
defaults
[
$name
],
$matches
[
$name
])
===
0
)
{
$tr
[
$token
]
=
''
;
$tr
[
"/
$token
/"
]
=
'/'
;
}
else
{
$tr
[
$token
]
=
$matches
[
$name
];
}
}
}
}
else
{
}
else
{
return
false
;
return
false
;
...
@@ -123,6 +128,9 @@ class UrlRule extends Object
...
@@ -123,6 +128,9 @@ class UrlRule extends Object
// match default params
// match default params
// if a default param is not in the route pattern, its value must also be matched
// if a default param is not in the route pattern, its value must also be matched
foreach
(
$this
->
defaults
as
$name
=>
$value
)
{
foreach
(
$this
->
defaults
as
$name
=>
$value
)
{
if
(
isset
(
$this
->
routeParams
[
$name
]))
{
continue
;
}
if
(
!
isset
(
$params
[
$name
]))
{
if
(
!
isset
(
$params
[
$name
]))
{
return
false
;
return
false
;
}
elseif
(
strcmp
(
$params
[
$name
],
$value
)
===
0
)
{
// strcmp will do string conversion automatically
}
elseif
(
strcmp
(
$params
[
$name
],
$value
)
===
0
)
{
// strcmp will do string conversion automatically
...
...
tests/unit/framework/web/UrlRuleTest.php
View file @
f31369e7
...
@@ -244,7 +244,6 @@ class UrlRuleTest extends \yiiunit\TestCase
...
@@ -244,7 +244,6 @@ class UrlRuleTest extends \yiiunit\TestCase
array
(
'post/index'
,
array
(
'controller'
=>
'comment'
),
'post/index?controller=comment'
),
array
(
'post/index'
,
array
(
'controller'
=>
'comment'
),
'post/index?controller=comment'
),
),
),
),
),
/* this is not supported
array
(
array
(
'route has default parameter'
,
'route has default parameter'
,
array
(
array
(
...
@@ -256,10 +255,10 @@ class UrlRuleTest extends \yiiunit\TestCase
...
@@ -256,10 +255,10 @@ class UrlRuleTest extends \yiiunit\TestCase
array
(
'post/view'
,
array
(
'page'
=>
1
),
'post/view?page=1'
),
array
(
'post/view'
,
array
(
'page'
=>
1
),
'post/view?page=1'
),
array
(
'comment/view'
,
array
(
'page'
=>
1
),
'comment/view?page=1'
),
array
(
'comment/view'
,
array
(
'page'
=>
1
),
'comment/view?page=1'
),
array
(
'test/view'
,
array
(
'page'
=>
1
),
false
),
array
(
'test/view'
,
array
(
'page'
=>
1
),
false
),
array
(
'test/index'
,
array
(
'page'
=>
1
),
false
),
array
(
'post/index'
,
array
(
'page'
=>
1
),
'post?page=1'
),
array
(
'post/index'
,
array
(
'page'
=>
1
),
'post?page=1'
),
),
),
),
),
*/
);
);
}
}
...
...
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