swarm-ui: open the terminal, group and flow pages for a malformed address
A name or id that isn't valid percent-encoding (for example /agents/%E0%A4%A/terminal) made decodeURIComponent throw while the page rendered, leaving a blank page. The segment now stays as typed, as the agents page already did, so the page opens (a terminal for that name, disconnected). A tested helper does the decoding.
This commit is contained in:
parent
c7e559a09e
commit
79f2d4bd4d
1 changed files with 30 additions and 6 deletions
|
|
@ -7,6 +7,7 @@ import {
|
|||
isFullBleedRoute,
|
||||
movedHref,
|
||||
pageOf,
|
||||
safeDecode,
|
||||
selectedAgent,
|
||||
visibleNavItems,
|
||||
} from "../src/shell/routes.ts";
|
||||
|
|
@ -113,3 +114,9 @@ test("an agent selected on the agents page is still the agents page", () => {
|
|||
assert.equal(pageOf("/agents/group/g1"), "/agents/group/g1");
|
||||
assert.equal(pageOf("/jobs"), "/jobs");
|
||||
});
|
||||
|
||||
test("a path segment decodes, and a malformed one comes back as typed", () => {
|
||||
assert.equal(safeDecode("my%20agent"), "my agent");
|
||||
assert.equal(safeDecode("plain"), "plain");
|
||||
assert.equal(safeDecode("%E0%A4%A"), "%E0%A4%A");
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue