summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-10-09 23:00:35 +0200
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-10-09 23:00:35 +0200
commitd70e5bfa8249416673d0dc6c177c2e4c5b6d7490 (patch)
tree687b68fd28314424ee5c2a9ae3edf59e5ed9c6cd /lib
parent044f4542baccc00ea6db4ec38cb0f65928242f61 (diff)
Utilise par défaut des adresses relatives
Sur ma page d'accueil, l'adresse absolue de FreshRSS est écrite 1300 fois, ce qui représente 15% de la taille de cette page (542Ko -> 460Ko). Ce patch utilise une adresse relative par défaut, beaucoup plus courte. De plus, dans le cas d'une adresse absolue, le protocole relatif "//" est utilisé pour utiliser automatiquement "http://" ou "https://". Pas testé avec url_rewriting.
Diffstat (limited to 'lib')
-rwxr-xr-xlib/minz/Url.php24
1 files changed, 10 insertions, 14 deletions
diff --git a/lib/minz/Url.php b/lib/minz/Url.php
index c1c3e9a0f..9bda98363 100755
--- a/lib/minz/Url.php
+++ b/lib/minz/Url.php
@@ -16,25 +16,21 @@ class Url {
* @param $encodage pour indiquer comment encoder les & (& ou &amp; pour html)
* @return l'url formatée
*/
- public static function display ($url = array (), $encodage = 'html') {
+ public static function display ($url = array (), $encodage = 'html', $absolute = false) {
$url = self::checkUrl ($url);
$url_string = '';
- if (is_array ($url) && isset ($url['protocol'])) {
- $protocol = $url['protocol'];
- } else {
- if(isset($_SERVER['HTTPS']) && $_SERVER["HTTPS"] == 'on') {
- $protocol = 'https';
- } else {
- $protocol = 'http';
- }
+ if ($absolute) {
+ $protocol = (is_array ($url) && isset ($url['protocol'])) ? ($url['protocol'] . ':') : ''; //Empty protocol will use automatic http or https
+ $url_string = $protocol
+ . '//'
+ . Request::getDomainName ()
+ . Request::getBaseUrl ();
+ }
+ else {
+ $url_string = '.';
}
- $url_string .= $protocol . '://';
-
- $url_string .= Request::getDomainName ();
-
- $url_string .= Request::getBaseUrl ();
if (is_array ($url)) {
$router = new Router ();