using PlotLine.Services.Context; internal static class ContextWorkspaceNavigationTests { public static void Run() { foreach(var url in new[]{"/Locations/Details/15", "/Locations/Edit/15", "/Characters/Edit/8", "/Maps?projectId=7&id=12&featureId=one", "/FloorPlans/Edit/5?selectedBlockId=44", "/StoryCalendar?bookId=12", "/Books/Details/12", "/manuscript/paragraphs?bookId=12", "/PlotThreads/Edit/8", "/RelationshipMap?sceneId=20"}) if(!ContextWorkspaceNavigation.IsAllowed(url))throw new Exception("Main page rejected: "+url); foreach(var url in new[]{"https://example.com/Maps", "//example.com/Maps", "/\\example.com/Maps", "/Maps\r\n", "/Maps/Save", "/FloorPlans/Delete/5", "/Writing/Context", "/Maps/../Account/Logout", "/%4daps"}) if(ContextWorkspaceNavigation.IsAllowed(url))throw new Exception("Unsafe or non-page route accepted: "+url); var root=Directory.GetCurrentDirectory(); while(!File.Exists(Path.Combine(root,"PlotLine.slnx")))root=Directory.GetParent(root)?.FullName??throw new Exception("Repository missing"); var script=File.ReadAllText(Path.Combine(root,"PlotLine/wwwroot/js/context-main-window.js")); if(!script.Contains("closest?.('a[href]')")||!script.Contains("/Writing\\/Context")||script.Contains("link.removeAttribute('data-context-workspace-target')")) throw new Exception("Context must delegate dynamically inserted main-page links and keep blocked links intercepted."); } }