Permalink
Browse files

Fixes to the Twig function for absoluting urls

  • Loading branch information...
1 parent eec20cb commit d2e3331d27734e3223f45d8d4d2697b0813b0fc5 @kolber committed Apr 4, 2013
Showing with 2 additions and 1 deletion.
  1. +2 −1 extensions/twig-extensions.inc.php
@@ -165,7 +165,8 @@ function sortby($object, $value) {
#
function absolute($relative_path) {
$server_name = (($_SERVER['HTTPS'] ? 'https://' : 'http://')).$_SERVER['HTTP_HOST'];
- return $server_name.str_replace('/index.php', strstr($relative_path, '/content'), $_SERVER['SCRIPT_NAME']);
+ $relative_path = preg_replace(array('/^\/content/', '/^(\.+\/)*/'), '', $relative_path);
+ return $server_name.str_replace('/index.php', $relative_path, $_SERVER['SCRIPT_NAME']);
}
}

0 comments on commit d2e3331

Please sign in to comment.