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
e433c98e
Commit
e433c98e
authored
Jul 23, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #599
parent
e3308996
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
12 additions
and
12 deletions
+12
-12
Module.php
framework/yii/base/Module.php
+0
-1
Request.php
framework/yii/web/Request.php
+3
-3
UrlManager.php
framework/yii/web/UrlManager.php
+2
-1
UrlRule.php
framework/yii/web/UrlRule.php
+1
-2
UrlManagerTest.php
tests/unit/framework/web/UrlManagerTest.php
+4
-4
UrlRuleTest.php
tests/unit/framework/web/UrlRuleTest.php
+2
-1
No files found.
framework/yii/base/Module.php
View file @
e433c98e
...
...
@@ -605,7 +605,6 @@ abstract class Module extends Component
if
(
$route
===
''
)
{
$route
=
$this
->
defaultRoute
;
}
$route
=
trim
(
$route
,
'/'
);
if
((
$pos
=
strpos
(
$route
,
'/'
))
!==
false
)
{
$id
=
substr
(
$route
,
0
,
$pos
);
$route
=
substr
(
$route
,
$pos
+
1
);
...
...
framework/yii/web/Request.php
View file @
e433c98e
...
...
@@ -417,13 +417,13 @@ class Request extends \yii\base\Request
*/
public
function
setPathInfo
(
$value
)
{
$this
->
_pathInfo
=
trim
(
$value
,
'/'
);
$this
->
_pathInfo
=
l
trim
(
$value
,
'/'
);
}
/**
* Resolves the path info part of the currently requested URL.
* A path info refers to the part that is after the entry script and before the question mark (query string).
* The starting
and ending slashes are both removed
.
* The starting
slashes are both removed (ending slashes will be kept)
.
* @return string part of the request URL that is after the entry script and before the question mark.
* Note, the returned path info is decoded.
* @throws InvalidConfigException if the path info cannot be determined due to unexpected server configuration
...
...
@@ -465,7 +465,7 @@ class Request extends \yii\base\Request
throw
new
InvalidConfigException
(
'Unable to determine the path info of the current request.'
);
}
return
trim
(
$pathInfo
,
'/'
);
return
l
trim
(
$pathInfo
,
'/'
);
}
/**
...
...
framework/yii/web/UrlManager.php
View file @
e433c98e
...
...
@@ -29,6 +29,7 @@ class UrlManager extends Component
/**
* @var boolean whether to enable strict parsing. If strict parsing is enabled, the incoming
* requested URL must match at least one of the [[rules]] in order to be treated as a valid request.
* Otherwise, the path info part of the request will be treated as the requested route.
* This property is used only when [[enablePrettyUrl]] is true.
*/
public
$enableStrictParsing
=
false
;
...
...
@@ -181,7 +182,7 @@ class UrlManager extends Component
}
$suffix
=
(
string
)
$this
->
suffix
;
if
(
$suffix
!==
''
&&
$
suffix
!==
'/'
&&
$
pathInfo
!==
''
)
{
if
(
$suffix
!==
''
&&
$pathInfo
!==
''
)
{
$n
=
strlen
(
$this
->
suffix
);
if
(
substr
(
$pathInfo
,
-
$n
)
===
$this
->
suffix
)
{
$pathInfo
=
substr
(
$pathInfo
,
0
,
-
$n
);
...
...
framework/yii/web/UrlRule.php
View file @
e433c98e
...
...
@@ -192,8 +192,7 @@ class UrlRule extends Object
// suffix alone is not allowed
return
false
;
}
}
elseif
(
$suffix
!==
'/'
)
{
// we allow the ending '/' to be optional if it is a suffix
}
else
{
return
false
;
}
}
...
...
tests/unit/framework/web/UrlManagerTest.php
View file @
e433c98e
...
...
@@ -163,9 +163,9 @@ class UrlManagerTest extends TestCase
$result
=
$manager
->
parseRequest
(
$request
);
$this
->
assertEquals
(
array
(
'module/site/index'
,
array
()),
$result
);
// pathinfo with trailing slashes
$request
->
pathInfo
=
'module/site/index/'
;
$request
->
pathInfo
=
'
/
module/site/index/'
;
$result
=
$manager
->
parseRequest
(
$request
);
$this
->
assertEquals
(
array
(
'module/site/index'
,
array
()),
$result
);
$this
->
assertEquals
(
array
(
'module/site/index
/
'
,
array
()),
$result
);
// pretty URL rules
$manager
=
new
UrlManager
(
array
(
...
...
@@ -182,10 +182,10 @@ class UrlManagerTest extends TestCase
$request
->
pathInfo
=
'post/123/this+is+sample'
;
$result
=
$manager
->
parseRequest
(
$request
);
$this
->
assertEquals
(
array
(
'post/view'
,
array
(
'id'
=>
'123'
,
'title'
=>
'this+is+sample'
)),
$result
);
//
matching pathinfo with trailing slashes
//
trailing slash is significant
$request
->
pathInfo
=
'post/123/this+is+sample/'
;
$result
=
$manager
->
parseRequest
(
$request
);
$this
->
assertEquals
(
array
(
'post/
view'
,
array
(
'id'
=>
'123'
,
'title'
=>
'this+is+sample'
)),
$result
);
$this
->
assertEquals
(
array
(
'post/
123/this+is+sample/'
,
array
(
)),
$result
);
// empty pathinfo
$request
->
pathInfo
=
''
;
$result
=
$manager
->
parseRequest
(
$request
);
...
...
tests/unit/framework/web/UrlRuleTest.php
View file @
e433c98e
...
...
@@ -620,7 +620,8 @@ class UrlRuleTest extends TestCase
'suffix'
=>
'/'
,
),
array
(
array
(
'posts'
,
'post/index'
),
array
(
'posts/'
,
'post/index'
),
array
(
'posts'
,
false
),
array
(
'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