mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX: Fixed Controller::join_links() handling of fragment identifiers (from r104580)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112352 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
589adbfde3
commit
9cc825e769
@ -558,7 +558,13 @@ class Controller extends RequestHandler {
|
||||
$args = func_get_args();
|
||||
$result = "";
|
||||
$querystrings = array();
|
||||
$fragmentIdentifier = null;
|
||||
foreach($args as $arg) {
|
||||
// Find fragment identifier - keep the last one
|
||||
if(strpos($arg,'#') !== false) {
|
||||
list($arg, $fragmentIdentifier) = explode('#',$arg,2);
|
||||
}
|
||||
// Find querystrings
|
||||
if(strpos($arg,'?') !== false) {
|
||||
list($arg, $suffix) = explode('?',$arg,2);
|
||||
$querystrings[] = $suffix;
|
||||
@ -570,6 +576,7 @@ class Controller extends RequestHandler {
|
||||
}
|
||||
|
||||
if($querystrings) $result .= '?' . implode('&', $querystrings);
|
||||
if($fragmentIdentifier) $result .= "#$fragmentIdentifier";
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
@ -102,6 +102,12 @@ class ControllerTest extends FunctionalTest {
|
||||
);
|
||||
|
||||
$this->assertEquals('/admin/action', Controller::join_links('/admin', 'action'));
|
||||
|
||||
/* One fragment identifier is handled as you would expect */
|
||||
$this->assertEquals("my-page?arg=var#subsection", Controller::join_links("my-page#subsection", "?arg=var"));
|
||||
|
||||
/* If there are multiple, it takes the last one */
|
||||
$this->assertEquals("my-page?arg=var#second-section", Controller::join_links("my-page#subsection", "?arg=var", "#second-section"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user