fix(ui): восстанавливать контекст OSPF из URL
This commit is contained in:
1 parent
af05ad5cda
commit
1d522527b4
7 files changed
+130
-44
No files matched your search
@@ -0,0 +1,12 @@
|
||||
import assert from "node:assert/strict"
|
||||
import { test } from "node:test"
|
||||
import { readOspfUrl, patchOspfUrl } from "./ospf-url-state"
|
||||
test("OSPF device/tab URL preserves unrelated context", () => {
|
||||
const url=patchOspfUrl(new URLSearchParams("keep=x"),{server:"2",tab:"bfd"})
|
||||
assert.deepEqual(readOspfUrl(new URL(url,"http://test").searchParams),{server:"2",tab:"bfd",error:null})
|
||||
assert.equal(patchOspfUrl(new URL(url,"http://test").searchParams,{server:null,tab:null}),"/ospf?keep=x")
|
||||
})
|
||||
test("invalid or repeated context is explicit instead of widening to all",()=>{
|
||||
for(const raw of ["server=a&server=b","tab=bfd&tab=neighbors","tab=broken","server=", "server="+"x".repeat(65),"server=%2F"]) assert.ok(readOspfUrl(new URLSearchParams(raw)).error)
|
||||
assert.equal(readOspfUrl(new URLSearchParams("server=srv1&tab=neighbors")).error,null)
|
||||
})
|
||||
Reference in new issue
Block a user