Skip to content
This repository has been archived by the owner on Jan 10, 2021. It is now read-only.

Commit

Permalink
[FIX] Resolves an issue where setting an alternate_base_url caused
Browse files Browse the repository at this point in the history
infinite redirections (since the mapping ended up with an absolute link).
  • Loading branch information
Nathan Glasl committed Mar 15, 2018
1 parent a91c373 commit bb223d2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# [misdirection](https://packagist.org/packages/nglasl/silverstripe-misdirection)

_The current release is **2.2.24**_
_The current release is **2.2.25**_

> A module for SilverStripe which will allow both simple and regular expression link redirections based on customisable mappings, either hooking into a page not found or replacing the default automated URL handling.
Expand Down
14 changes: 13 additions & 1 deletion code/dataobjects/LinkMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,19 @@ public function getLink() {

// When appropriate, prepend the base URL to match a page redirection.

return MisdirectionService::is_external_URL($link) ? (ClassInfo::exists('Multisites') ? HTTP::setGetVar('misdirected', true, $link) : $link) : Controller::join_links(Director::baseURL(), $link);
$prepended = Controller::join_links(Director::baseURL(), $link);
if(MisdirectionService::is_external_URL($link)) {
return ClassInfo::exists('Multisites') ? HTTP::setGetVar('misdirected', true, $link) : $link;
}

// This is needed, otherwise infinitely recursive mappings won't be detected in advance.

else if(MisdirectionService::is_external_URL($prepended)) {
return $link;
}
else {
return $prepended;
}
}
}

Expand Down

0 comments on commit bb223d2

Please sign in to comment.