From 60e92ac9dc7e4af6f3aab2d56bdb652144790ef7 Mon Sep 17 00:00:00 2001 From: Stephan Yelle Date: Sat, 24 Jan 2026 22:58:41 -0500 Subject: [PATCH] Update src/router.ps1 --- src/router.ps1 | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/router.ps1 b/src/router.ps1 index 1e82597..67a5b1d 100644 --- a/src/router.ps1 +++ b/src/router.ps1 @@ -7,8 +7,45 @@ function Invoke-TasksCompleted { function Dispatch-Request { param($Context) + # Normalize path $path = $Context.Request.Url.AbsolutePath.TrimStart('/') + # Normalize path +$path = $Context.Request.Url.AbsolutePath.TrimStart('/') + +switch -Regex ($path) { + + '^$' { + # / + return Send-RemoteAsset -Context $Context -Url $Script:SamyHtmlUrl -ContentType 'text/html; charset=utf-8' + } + + '^samy\.js$' { + return Send-RemoteAsset -Context $Context -Url $Script:SamyJsUrl -ContentType 'application/javascript; charset=utf-8' + } + + '^samy\.css$' { + return Send-RemoteAsset -Context $Context -Url $Script:SamyCssUrl -ContentType 'text/css; charset=utf-8' + } + + '^SVS_logo\.svg$' { + return Send-RemoteAsset -Context $Context -Url $Script:SamyTopLogoUrl -ContentType 'image/svg+xml' + } + + '^SAMY\.png$' { + return Send-RemoteAsset -Context $Context -Url $Script:SamyBgLogoUrl -ContentType 'image/png' + } + + '^SVS_Favicon\.ico$' { + return Send-RemoteAsset -Context $Context -Url $Script:SamyFaviconUrl -ContentType 'image/x-icon' + } + + default { + # Continue into your existing API/task routing + } +} + + if ($path -eq 'quit') { Write-LogHybrid "Shutdown requested" "Info" "Server" -LogToEvent Send-Text $Context "Server shutting down."