]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - application/http/HttpUtils.php
Process Daily RSS feed through Slim controller
[github/shaarli/Shaarli.git] / application / http / HttpUtils.php
index 2ea9195d3550bfd4bfd912ef35cb4b669a5c83c2..f00c4336ad07fb24d3a798fc123f1dad24dbec77 100644 (file)
@@ -369,7 +369,7 @@ function server_url($server)
  */
 function index_url($server)
 {
-    $scriptname = $server['SCRIPT_NAME'];
+    $scriptname = $server['SCRIPT_NAME'] ?? '';
     if (endsWith($scriptname, 'index.php')) {
         $scriptname = substr($scriptname, 0, -9);
     }
@@ -377,7 +377,7 @@ function index_url($server)
 }
 
 /**
- * Returns the absolute URL of the current script, with the query
+ * Returns the absolute URL of the current script, with current route and query
  *
  * If the resource is "index.php", then it is removed (for better-looking URLs)
  *
@@ -387,10 +387,17 @@ function index_url($server)
  */
 function page_url($server)
 {
+    $scriptname = $server['SCRIPT_NAME'] ?? '';
+    if (endsWith($scriptname, 'index.php')) {
+        $scriptname = substr($scriptname, 0, -9);
+    }
+
+    $route = ltrim($server['REQUEST_URI'] ?? '', $scriptname);
     if (! empty($server['QUERY_STRING'])) {
-        return index_url($server).'?'.$server['QUERY_STRING'];
+        return index_url($server) . $route . '?' . $server['QUERY_STRING'];
     }
-    return index_url($server);
+
+    return index_url($server) . $route;
 }
 
 /**