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
11923064
Commit
11923064
authored
Jun 03, 2013
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improved UrlManager RESTful syntax regex
parent
fbb93d0b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
9 deletions
+6
-9
UrlManager.php
framework/yii/web/UrlManager.php
+6
-9
No files found.
framework/yii/web/UrlManager.php
View file @
11923064
...
@@ -45,11 +45,11 @@ class UrlManager extends Component
...
@@ -45,11 +45,11 @@ class UrlManager extends Component
*
*
* For RESTful routing the mentioned shortcut format also allows you to specify the
* For RESTful routing the mentioned shortcut format also allows you to specify the
* [[UrlRule::verb|HTTP verb]] that the rule should apply for.
* [[UrlRule::verb|HTTP verb]] that the rule should apply for.
* You can do that by prepending it to the pattern, separated by
a
space.
* You can do that by prepending it to the pattern, separated by space.
* For example, `'PUT post/<id:\d+>' => 'post/update'`.
* For example, `'PUT post/<id:\d+>' => 'post/update'`.
* You may specify multiple verbs by separating them with comma
* You may specify multiple verbs by separating them with comma
* like this: `'POST,PUT post/index' => 'post/create'`.
* like this: `'POST,PUT post/index' => 'post/create'`.
* The supported verbs in the shortcut format are: GET, POST, PUT and DELETE.
* The supported verbs in the shortcut format are: GET,
HEAD,
POST, PUT and DELETE.
* Note that [[UrlRule::mode|mode]] will be set to PARSING_ONLY when specifying verb in this way
* Note that [[UrlRule::mode|mode]] will be set to PARSING_ONLY when specifying verb in this way
* so you normally would not specify a verb for normal GET request.
* so you normally would not specify a verb for normal GET request.
*
*
...
@@ -142,13 +142,10 @@ class UrlManager extends Component
...
@@ -142,13 +142,10 @@ class UrlManager extends Component
$rule
=
array
(
$rule
=
array
(
'route'
=>
$rule
,
'route'
=>
$rule
,
);
);
if
((
$pos
=
strpos
(
$key
,
' '
))
!==
false
)
{
if
(
preg_match
(
'/^((?:(GET|HEAD|POST|PUT|DELETE),)*(GET|HEAD|POST|PUT|DELETE))\s+(.*)$/'
,
$key
,
$matches
))
{
$verbs
=
substr
(
$key
,
0
,
$pos
);
$rule
[
'verb'
]
=
explode
(
','
,
$matches
[
1
]);
if
(
preg_match
(
'/^((GET|POST|PUT|DELETE),?)*$/'
,
$verbs
,
$matches
))
{
$rule
[
'mode'
]
=
UrlRule
::
PARSING_ONLY
;
$rule
[
'verb'
]
=
explode
(
','
,
$verbs
);
$key
=
$matches
[
4
];
$rule
[
'mode'
]
=
UrlRule
::
PARSING_ONLY
;
$key
=
substr
(
$key
,
$pos
+
1
);
}
}
}
$rule
[
'pattern'
]
=
$key
;
$rule
[
'pattern'
]
=
$key
;
}
}
...
...
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