From 5ebf534ba7e90ccb12007c137ecea1cfcc4876da Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Sat, 13 Dec 2014 15:28:05 +0100 Subject: Avoid double slashes in notification email body Refactor some of the URI generation code to avoid double slashes in absolute URIs. Signed-off-by: Lukas Fleischer --- web/lib/routing.inc.php | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'web/lib/routing.inc.php') diff --git a/web/lib/routing.inc.php b/web/lib/routing.inc.php index 833ea0f..1ee2e35 100644 --- a/web/lib/routing.inc.php +++ b/web/lib/routing.inc.php @@ -37,8 +37,12 @@ function get_route($path) { } } -function get_uri($path) { - return $path; +function get_uri($path, $absolute=false) { + if ($absolute) { + return rtrim(aur_location(), '/') . $path; + } else { + return $path; + } } function get_pkg_route() { @@ -56,14 +60,16 @@ function get_pkgreq_route() { return $PKGREQ_PATH; } -function get_pkg_uri($pkgname) { +function get_pkg_uri($pkgname, $absolute=false) { global $PKG_PATH; - return $PKG_PATH . '/' . urlencode($pkgname) . '/'; + $path = $PKG_PATH . '/' . urlencode($pkgname) . '/'; + return get_uri($path, $absolute); } -function get_pkgbase_uri($pkgbase_name) { +function get_pkgbase_uri($pkgbase_name, $absolute=false) { global $PKGBASE_PATH; - return $PKGBASE_PATH . '/' . urlencode($pkgbase_name) . '/'; + $path = $PKGBASE_PATH . '/' . urlencode($pkgbase_name) . '/'; + return get_uri($path, $absolute); } function get_user_route() { @@ -71,7 +77,8 @@ function get_user_route() { return $USER_PATH; } -function get_user_uri($username) { +function get_user_uri($username, $absolute=false) { global $USER_PATH; - return $USER_PATH . '/' . urlencode($username) . '/'; + $path = $USER_PATH . '/' . urlencode($username) . '/'; + return get_uri($path, $absolute); } -- cgit v1.2.3-54-g00ecf