getUrlParameter.php 603 B

12345678910111213
  1. <?php
  2. // Nextcloud deduplicates subsequent slashes in the path, so our $url route parameter will have been
  3. // corrupted to http:/something. As a workaround, we manually read the URL from the unmodified path.
  4. function getUrlParameter($routeName) {
  5. $path = $_SERVER['REQUEST_URI'];
  6. $routePath = "apps/memento/$routeName/"; // (presumably nobody has this string in their web root)
  7. $index = strpos($path, $routePath);
  8. if ($index === false) {
  9. throw new Exception("Cannot get URL parameter from unexpected path '$path'.");
  10. }
  11. $url = substr($path, $index + strlen($routePath));
  12. return $url;
  13. }