From 969dfaf9439e69c4527f620ccda0676860eaf32f Mon Sep 17 00:00:00 2001 From: Zaid Humaimidi Date: Sun, 29 Mar 2026 12:58:36 -0700 Subject: [PATCH] Revert "Fix device ID parsing regression in Mithril 2.3.8" This reverts commit f9ee39dfd0eb32a3c9e2ec0b0d4af4f753e7d834. --- ui/device-page.ts | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/ui/device-page.ts b/ui/device-page.ts index 70e19db..55cf984 100644 --- a/ui/device-page.ts +++ b/ui/device-page.ts @@ -3,29 +3,6 @@ import { m } from "./components.ts"; import config from "./config.ts"; import * as store from "./store.ts"; -// Workaround for Mithril 2.3.8 regression -// https://github.com/MithrilJS/mithril.js/issues/3064 -function getPathParamFromHash(hash: string, prefix: string): string | null { - if (!hash.startsWith(prefix)) return null; - - const pathWithQuery = hash.slice(prefix.length); - - // Stop at query string or hash fragment (mirrors Mithril's parsePathname) - const queryIdx = pathWithQuery.indexOf("?"); - const hashIdx = pathWithQuery.indexOf("#"); - let pathEnd = pathWithQuery.length; - if (queryIdx >= 0) pathEnd = Math.min(pathEnd, queryIdx); - if (hashIdx >= 0) pathEnd = Math.min(pathEnd, hashIdx); - - const rawPath = pathWithQuery.slice(0, pathEnd); - - // Normalize: collapse slashes, remove trailing slash (matches Mithril) - const normalizedPath = rawPath.replace(/\/{2,}/g, "/").replace(/\/$/, ""); - - // Decode once (Mithril already decoded with decodeURIComponentSafe) - return decodeURIComponent(normalizedPath); -} - export function init( args: Record, ): Promise> { @@ -35,13 +12,9 @@ export function init( ); } - const deviceId = - getPathParamFromHash(window.location.hash, "#!/devices/") ?? - (args.id as string); - return Promise.resolve({ - deviceId: deviceId, - deviceFilter: ["=", ["PARAM", "DeviceID.ID"], deviceId], + deviceId: args.id, + deviceFilter: ["=", ["PARAM", "DeviceID.ID"], args.id], }); }