Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
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
Yeray Santana Hualde
syncEnrollments
Commits
c47a30fc
Commit
c47a30fc
authored
Jan 12, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug in router parameter parsing.
parent
339d3a84
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
34 deletions
+4
-34
router.php
laravel/routing/router.php
+4
-34
No files found.
laravel/routing/router.php
View file @
c47a30fc
...
@@ -157,9 +157,11 @@ class Router {
...
@@ -157,9 +157,11 @@ class Router {
{
{
foreach
(
explode
(
', '
,
$keys
)
as
$key
)
foreach
(
explode
(
', '
,
$keys
)
as
$key
)
{
{
if
(
preg_match
(
'#^'
.
$this
->
wildcards
(
$key
)
.
'$#'
,
$destination
))
if
(
preg_match
(
'#^'
.
$this
->
wildcards
(
$key
)
.
'$#'
,
$destination
,
$parameters
))
{
{
return
new
Route
(
$keys
,
$callback
,
$this
->
parameters
(
$destination
,
$key
));
array_shift
(
$parameters
);
return
new
Route
(
$keys
,
$callback
,
$parameters
);
}
}
}
}
}
}
...
@@ -253,36 +255,4 @@ class Router {
...
@@ -253,36 +255,4 @@ class Router {
return
str_replace
(
array_keys
(
$this
->
patterns
),
array_values
(
$this
->
patterns
),
$key
);
return
str_replace
(
array_keys
(
$this
->
patterns
),
array_values
(
$this
->
patterns
),
$key
);
}
}
/**
* Extract the parameters from a URI based on a route URI.
*
* Any route segment wrapped in parentheses is considered a parameter.
*
* @param string $uri
* @param string $route
* @return array
*/
protected
function
parameters
(
$uri
,
$route
)
{
list
(
$uri
,
$route
)
=
array
(
explode
(
'/'
,
$uri
),
explode
(
'/'
,
$route
));
$count
=
count
(
$route
);
$parameters
=
array
();
// To find the parameters that should be passed to the route, we will
// iterate through the route segments, and if the segment is enclosed
// in parentheses, we will take the matching segment from the request
// URI and add it to the array of parameters.
for
(
$i
=
0
;
$i
<
$count
;
$i
++
)
{
if
(
preg_match
(
'/\(.+\)/'
,
$route
[
$i
])
and
isset
(
$uri
[
$i
]))
{
$parameters
[]
=
$uri
[
$i
];
}
}
return
$parameters
;
}
}
}
\ No newline at end of file
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