Normalize URLs for server status matching and update error page titles
This commit is contained in:
parent
9020a7f7a3
commit
f6fd033c21
2
404.php
2
404.php
@ -6,7 +6,7 @@ http_response_code(404);
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>404 – Seite nicht gefunden · Fabian Schieder</title>
|
<title>Seite nicht gefunden · Fabian Schieder</title>
|
||||||
<link rel="stylesheet" href="/style.css">
|
<link rel="stylesheet" href="/style.css">
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
|
|||||||
2
503.php
2
503.php
@ -6,7 +6,7 @@ http_response_code(503);
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>404 – Seite nicht gefunden · Fabian Schieder</title>
|
<title>Dienst nicht verfügbar · Fabian Schieder</title>
|
||||||
<link rel="stylesheet" href="/style.css">
|
<link rel="stylesheet" href="/style.css">
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
|
|||||||
@ -5,6 +5,45 @@
|
|||||||
* - $items (array)
|
* - $items (array)
|
||||||
* - $serverStatusByUrl (array)
|
* - $serverStatusByUrl (array)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Hilfsfunktion: URLs für Status-Matching normalisieren (z.B. /nextcloud vs /nextcloud/)
|
||||||
|
$__normalize_status_url = static function (string $url): string {
|
||||||
|
$u = trim($url);
|
||||||
|
if ($u === '') return $u;
|
||||||
|
|
||||||
|
// Nur Trailing Slash entfernen (aber nicht bei "https://host/")
|
||||||
|
$parts = parse_url($u);
|
||||||
|
if (!is_array($parts) || empty($parts['scheme']) || empty($parts['host'])) {
|
||||||
|
return rtrim($u, '/');
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = $parts['path'] ?? '';
|
||||||
|
if (is_string($path) && $path !== '' && $path !== '/') {
|
||||||
|
$parts['path'] = rtrim($path, '/');
|
||||||
|
if ($parts['path'] === '') {
|
||||||
|
$parts['path'] = '/';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$normalized = strtolower((string)$parts['scheme']) . '://' . (string)$parts['host'];
|
||||||
|
if (!empty($parts['port'])) {
|
||||||
|
$normalized .= ':' . (string)$parts['port'];
|
||||||
|
}
|
||||||
|
$normalized .= (string)($parts['path'] ?? '');
|
||||||
|
if (!empty($parts['query'])) {
|
||||||
|
$normalized .= '?' . (string)$parts['query'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $normalized;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Normalisierte Map bauen (damit das Matching tolerant ist)
|
||||||
|
$__serverStatusByUrlNormalized = [];
|
||||||
|
foreach ($serverStatusByUrl as $__u => $__svc) {
|
||||||
|
if (is_string($__u)) {
|
||||||
|
$__serverStatusByUrlNormalized[$__normalize_status_url($__u)] = $__svc;
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<section>
|
<section>
|
||||||
<h2 class="category-title">
|
<h2 class="category-title">
|
||||||
@ -19,20 +58,21 @@
|
|||||||
$statusKey = null;
|
$statusKey = null;
|
||||||
|
|
||||||
// 1) Externe absolute URL direkt matchen
|
// 1) Externe absolute URL direkt matchen
|
||||||
if (!empty($project['url']) && isset($serverStatusByUrl[$project['url']])) {
|
if (!empty($project['url']) && isset($__serverStatusByUrlNormalized[$__normalize_status_url((string)$project['url'])])) {
|
||||||
$statusKey = $project['url'];
|
$statusKey = $__normalize_status_url((string)$project['url']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2) Interne Pfade (/git, /nextcloud) auf Domain mappen
|
// 2) Interne Pfade (/git, /nextcloud) auf Domain mappen
|
||||||
if ($statusKey === null && !empty($project['url']) && is_string($project['url']) && substr($project['url'], 0, 1) === '/') {
|
if ($statusKey === null && !empty($project['url']) && is_string($project['url']) && substr($project['url'], 0, 1) === '/') {
|
||||||
$statusKeyCandidate = 'https://fabianschieder.com' . $project['url'];
|
$statusKeyCandidate = 'https://fabianschieder.com' . $project['url'];
|
||||||
if (isset($serverStatusByUrl[$statusKeyCandidate])) {
|
$statusKeyCandidate = $__normalize_status_url($statusKeyCandidate);
|
||||||
|
if (isset($__serverStatusByUrlNormalized[$statusKeyCandidate])) {
|
||||||
$statusKey = $statusKeyCandidate;
|
$statusKey = $statusKeyCandidate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($statusKey !== null) {
|
if ($statusKey !== null) {
|
||||||
$status = $serverStatusByUrl[$statusKey];
|
$status = $__serverStatusByUrlNormalized[$statusKey];
|
||||||
}
|
}
|
||||||
|
|
||||||
$state = $status ? (string)($status['state'] ?? 'unknown') : null;
|
$state = $status ? (string)($status['state'] ?? 'unknown') : null;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user