Commit 39ddc47b authored by Sean Madsen's avatar Sean Madsen

Fix infinite redirect loop

The redirects stored for a book should not include the book's path.

Resolve #83
parent f2781413
......@@ -92,9 +92,6 @@ class Version {
$redirects = array($redirects);
}
// Remove alias for $path if it exists
unset($redirects[$this->path]);
// Add alias for $branch (e.g. so urls with "master" will work correctly)
$redirects[] = $this->branch;
......@@ -106,8 +103,11 @@ class Version {
$redirect = StringTools::urlSafe($redirect);
}
// Make sure we don't have any duplicate branches
// Make sure we don't have any duplicate redirects
$this->redirects = array_unique($redirects);
// Ensure that $path is not a redirect (to avoid infinite redirect loops)
$this->redirects = array_diff($this->redirects, [$this->path]);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment