From 81e074b7c36b9b6cca98d94928e1437366a8c735 Mon Sep 17 00:00:00 2001 From: SantaSpeen Date: Sun, 22 Nov 2026 20:58:43 +0300 Subject: [PATCH] Match Windows version discovery response and route forms --- Sources/EzServerMac/LocalServer.swift | 14 +++++++++++--- server/router.php | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Sources/EzServerMac/LocalServer.swift b/Sources/EzServerMac/LocalServer.swift index 372f778..bcccab3 100644 --- a/Sources/EzServerMac/LocalServer.swift +++ b/Sources/EzServerMac/LocalServer.swift @@ -13,7 +13,7 @@ private struct VersionList: Encodable { let errorCode = 0 let serverName = "EzWebServer" let currentVersionName = "3.0.6" - let currentStageVersionName = "0" + let currentStageVersionName = 0 let versions: [APIVersion] } @@ -203,7 +203,13 @@ final class LocalServer { "3.0.0", "3.0.1", "3.0.2", "3.0.3", "3.0.4", "3.0.5", "3.0.6" ].map { APIVersion(name: $0, url: apiURL, supportStatus: "supported") } let listing = VersionList(versions: versions) - let path = target.path.lowercased().trimmingCharacters(in: CharacterSet(charactersIn: "/")) + let versionPath = Array(lower.dropFirst(apiPrefix)) + let versionNameInPath = versionPath.count == 4 && + versionPath.starts(with: ["info", "versionsbyname", "name"]) && + (lower.starts(with: ["api", "v1"]) || apiPrefix == 3) ? segments.last : nil + let path = versionNameInPath == nil + ? target.path.lowercased().trimmingCharacters(in: CharacterSet(charactersIn: "/")) + : "api/v1/info/versionsbyname" switch path { case "", "health": send(["service": "EzServer Mac", "status": "ok"], on: connection) @@ -222,7 +228,9 @@ final class LocalServer { case "api/v1/info/versions", "api/index.php/v1/info/versions": send(listing, on: connection) case "api/v1/info/versionsbyname", "api/index.php/v1/info/versionsbyname": - let name = target.queryItems?.first(where: { $0.name == "name" })?.value ?? "" + let name = versionNameInPath + ?? target.queryItems?.first(where: { $0.name == "name" })?.value + ?? "" let match = versions.first { $0.name == name } ?? APIVersion(name: name, url: "", supportStatus: "unknown") send(VersionMatch(clientVersion: match, serverVersion: versions[versions.count - 1]), on: connection) default: diff --git a/server/router.php b/server/router.php index b2deccd..78bbd06 100644 --- a/server/router.php +++ b/server/router.php @@ -29,7 +29,7 @@ if ($path === '/') { $patientLookup = getenv('EZSERVER_SQLITE') && preg_match('~\A/api(?:/index\.php)?/v1/e2ds/patientsbychartno/?\z~i', $path ?? ''); -if (!$patientLookup && !preg_match('~\A/api(?:/index\.php)?(?:/v1/(?:auth/ping|info/(?:versions|versionsbyname)))?/?\z~i', $path ?? '')) { +if (!$patientLookup && !preg_match('~\A/api(?:/index\.php)?(?:/v1/(?:auth/ping|info/(?:versions|versionsbyname(?:/name/[^/]+)?)))?/?\z~i', $path ?? '')) { failRequest(404, 'Route is unavailable in the macOS preview'); return; }