diff --git a/Twig/Extension/FileManagementExtension.php b/Twig/Extension/FileManagementExtension.php index f5488c9..20605d4 100644 --- a/Twig/Extension/FileManagementExtension.php +++ b/Twig/Extension/FileManagementExtension.php @@ -36,7 +36,10 @@ public function filepath($entity, $propertyName) return null; } - return $this->webDirectory.$filePath; + return sprintf('%s/%s', + rtrim($this->webDirectory, '/'), + ltrim($filePath, '/') + ); } public function imagepath($entity, $propertyName, $format, $updateCache = true) @@ -82,10 +85,10 @@ private function getUrl($path) return null; } - return sprintf('%s://%s%s', + return sprintf('%s://%s/%s', $this->generator->getContext()->getScheme(), - $this->generator->getContext()->getHost(), - $path + rtrim($this->generator->getContext()->getHost(), '/'), + ltrim($path, '/') ); } }