Merge pull request #107 from webbuilders-group/image-path-rewrite-fix

BUGFIX: Fixed case where image urls could end up having a backslash on windows
This commit is contained in:
Daniel Hensby 2016-03-11 17:12:39 +00:00
commit 5d28a93e9f

View File

@ -238,16 +238,16 @@ class DocumentationParser
} }
// Rewrite URL (relative or absolute) // Rewrite URL (relative or absolute)
$baselink = DocumentationHelper::relativePath( $baselink = DocumentationHelper::relativePath(DocumentationHelper::normalizePath(
dirname($page->getPath()) dirname($page->getPath())
); ));
// if the image starts with a slash, it's absolute // if the image starts with a slash, it's absolute
if (substr($url, 0, 1) == '/') { if (substr($url, 0, 1) == '/') {
$relativeUrl = str_replace(BASE_PATH, '', Controller::join_links( $relativeUrl = DocumentationHelper::normalizePath(str_replace(BASE_PATH, '', Controller::join_links(
$page->getEntity()->getPath(), $page->getEntity()->getPath(),
$url $url
)); )));
} else { } else {
$relativeUrl = rtrim($baselink, '/') . '/' . ltrim($url, '/'); $relativeUrl = rtrim($baselink, '/') . '/' . ltrim($url, '/');
} }