Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
219
Merge Requests
219
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
966aed8f
Commit
966aed8f
authored
Sep 18, 2014
by
alexpott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2340379
by larowlan: Allow PathValidator::getUrlIfValid to support paths with leading /.
parent
f6d2f233
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
3 deletions
+11
-3
core/lib/Drupal/Core/Path/PathValidator.php
core/lib/Drupal/Core/Path/PathValidator.php
+1
-0
core/tests/Drupal/Tests/Core/Path/PathValidatorTest.php
core/tests/Drupal/Tests/Core/Path/PathValidatorTest.php
+10
-3
No files found.
core/lib/Drupal/Core/Path/PathValidator.php
View file @
966aed8f
...
...
@@ -102,6 +102,7 @@ public function getUrlIfValid($path) {
return
Url
::
createFromPath
(
$path
);
}
$path
=
ltrim
(
$path
,
'/'
);
$request
=
Request
::
create
(
'/'
.
$path
);
$attributes
=
$this
->
getPathAttributes
(
$path
,
$request
);
...
...
core/tests/Drupal/Tests/Core/Path/PathValidatorTest.php
View file @
966aed8f
...
...
@@ -246,16 +246,16 @@ public function testIsValidWithNotExistingPath() {
* Tests the getUrlIfValid() method when there is access.
*/
public
function
testGetUrlIfValidWithAccess
()
{
$this
->
account
->
expects
(
$this
->
once
(
))
$this
->
account
->
expects
(
$this
->
exactly
(
2
))
->
method
(
'hasPermission'
)
->
with
(
'link to any page'
)
->
willReturn
(
FALSE
);
$this
->
accessAwareRouter
->
expects
(
$this
->
once
(
))
$this
->
accessAwareRouter
->
expects
(
$this
->
exactly
(
2
))
->
method
(
'match'
)
->
with
(
'/test-path'
)
->
willReturn
([
RouteObjectInterface
::
ROUTE_NAME
=>
'test_route'
,
'_raw_variables'
=>
new
ParameterBag
([
'key'
=>
'value'
])]);
$this
->
pathProcessor
->
expects
(
$this
->
once
(
))
$this
->
pathProcessor
->
expects
(
$this
->
exactly
(
2
))
->
method
(
'processInbound'
)
->
willReturnArgument
(
0
);
...
...
@@ -264,6 +264,13 @@ public function testGetUrlIfValidWithAccess() {
$this
->
assertEquals
(
'test_route'
,
$url
->
getRouteName
());
$this
->
assertEquals
([
'key'
=>
'value'
],
$url
->
getRouteParameters
());
// Test with leading /.
$url
=
$this
->
pathValidator
->
getUrlIfValid
(
'/test-path'
);
$this
->
assertInstanceOf
(
'Drupal\Core\Url'
,
$url
);
$this
->
assertEquals
(
'test_route'
,
$url
->
getRouteName
());
$this
->
assertEquals
([
'key'
=>
'value'
],
$url
->
getRouteParameters
());
}
/**
...
...
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