diff options
author | Lukas Fleischer <archlinux@cryptocrack.de> | 2014-12-13 15:28:05 +0100 |
---|---|---|
committer | Lukas Fleischer <archlinux@cryptocrack.de> | 2014-12-13 15:28:54 +0100 |
commit | 5ebf534ba7e90ccb12007c137ecea1cfcc4876da (patch) | |
tree | 7bee294ccb46e920288990d6fe1b2f6c46c2cd6f /web/lib/routing.inc.php | |
parent | aa2724bbfee4b2504a4e9d27e06037639c3bc3cc (diff) | |
download | aur-5ebf534ba7e90ccb12007c137ecea1cfcc4876da.tar.gz aur-5ebf534ba7e90ccb12007c137ecea1cfcc4876da.tar.xz |
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 <archlinux@cryptocrack.de>
Diffstat (limited to 'web/lib/routing.inc.php')
-rw-r--r-- | web/lib/routing.inc.php | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/web/lib/routing.inc.php b/web/lib/routing.inc.php index 833ea0f1..1ee2e35c 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); } |