summaryrefslogtreecommitdiff
path: root/app/Helpers
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@webtrees.net>2019-11-16 16:06:10 +0000
committerGreg Roach <fisharebest@webtrees.net>2019-11-16 16:06:10 +0000
commit98116b24f349a13d59c9798d52b3efc6d56bfa47 (patch)
tree11534671a37ca5f32e723ed8d51d17a663d4fdd8 /app/Helpers
parentb972b8c97e1dc2a2c6177a5e17a260f556243431 (diff)
downloadwebtrees-98116b24f349a13d59c9798d52b3efc6d56bfa47.tar.gz
webtrees-98116b24f349a13d59c9798d52b3efc6d56bfa47.tar.bz2
webtrees-98116b24f349a13d59c9798d52b3efc6d56bfa47.zip
Fix: routing fails for URLs with port number. Add support for built-in server with pretty URLs.
Diffstat (limited to 'app/Helpers')
-rw-r--r--app/Helpers/functions.php24
1 files changed, 3 insertions, 21 deletions
diff --git a/app/Helpers/functions.php b/app/Helpers/functions.php
index 6c799877f8..0338c820ff 100644
--- a/app/Helpers/functions.php
+++ b/app/Helpers/functions.php
@@ -167,23 +167,6 @@ function route(string $route_name, array $parameters = []): string
$router_container = app(RouterContainer::class);
$route = $router_container->getMap()->getRoute($route_name);
- // Scheme/user/pass/host needed for absolute URLs.
- static $prefix = null;
-
- if ($prefix === null) {
- $base_url = $request->getAttribute('base_url');
- $base_parts = parse_url($base_url);
- $prefix = $base_parts['scheme'] . '://';
- if (array_key_exists('user', $base_parts)) {
- $prefix .= rawurlencode($base_parts['user']);
- if (array_key_exists('pass', $base_parts)) {
- $prefix .= ':' . rawurlencode($base_parts['pass']);
- }
- $prefix .= '@';
- }
- $prefix .= $base_parts['host'];
- }
-
// Generate the URL.
$url = $router_container->getGenerator()->generate($route_name, $parameters);
@@ -194,14 +177,13 @@ function route(string $route_name, array $parameters = []): string
// Turn the pretty URL into an ugly one.
if ($request->getAttribute('rewrite_urls') !== '1') {
+ $base_url = $request->getAttribute('base_url');
$path = parse_url($url, PHP_URL_PATH);
$parameters = ['route' => $path] + $parameters;
- $base_url = $request->getAttribute('base_url');
- $base_path = parse_url($base_url, PHP_URL_PATH) ?? '';
- $url = $base_path . '/index.php';
+ $url = $base_url . '/index.php';
}
- return Html::url($prefix . $url, $parameters);
+ return Html::url($url, $parameters);
}
/**