mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
FIX: Treat absolute links in a consistent manner in get_by_link.
Fixes #2580 The call to `Director::makeRelative` transforms absolute links into relative links. Previously, this meant that you could pass in "https://example.co.nz/about-us" or "about-us" and get the same result, but passing in "https://example.co.nz/" and "/" would give _different_ results. This commit performs the transformation to a relative link _before_ checking if the path should be for the home page, which leads to more consistent results.
This commit is contained in:
parent
f3a76ccf2d
commit
734eb3921f
@ -415,9 +415,8 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
|
|||||||
$urlSegmentExpr = sprintf('"%s"."URLSegment"', $tableName);
|
$urlSegmentExpr = sprintf('"%s"."URLSegment"', $tableName);
|
||||||
$parentIDExpr = sprintf('"%s"."ParentID"', $tableName);
|
$parentIDExpr = sprintf('"%s"."ParentID"', $tableName);
|
||||||
|
|
||||||
if (trim($link, '/')) {
|
$link = trim(Director::makeRelative($link), '/');
|
||||||
$link = trim(Director::makeRelative($link), '/');
|
if (!$link) {
|
||||||
} else {
|
|
||||||
$link = RootURLController::get_homepage_link();
|
$link = RootURLController::get_homepage_link();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user