mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
support empty strings for rooms segment
This commit is contained in:
parent
7b13e45e19
commit
d9c8a6339e
@ -69,7 +69,7 @@ export function parseUrlPath(urlPath, currentNavPath) {
|
|||||||
const type = next.value;
|
const type = next.value;
|
||||||
if (type === "rooms") {
|
if (type === "rooms") {
|
||||||
const roomsValue = iterator.next().value;
|
const roomsValue = iterator.next().value;
|
||||||
if (!roomsValue) { break; }
|
if (roomsValue === undefined) { break; }
|
||||||
const roomIds = roomsValue.split(",");
|
const roomIds = roomsValue.split(",");
|
||||||
segments.push(new Segment(type, roomIds));
|
segments.push(new Segment(type, roomIds));
|
||||||
const selectedIndex = parseInt(iterator.next().value || "0", 10);
|
const selectedIndex = parseInt(iterator.next().value || "0", 10);
|
||||||
@ -168,6 +168,26 @@ export function tests() {
|
|||||||
assert.equal(segments[2].type, "room");
|
assert.equal(segments[2].type, "room");
|
||||||
assert.equal(segments[2].value, "b");
|
assert.equal(segments[2].value, "b");
|
||||||
},
|
},
|
||||||
|
"parse empty grid url": assert => {
|
||||||
|
const segments = parseUrlPath("/session/1/rooms/");
|
||||||
|
assert.equal(segments.length, 3);
|
||||||
|
assert.equal(segments[0].type, "session");
|
||||||
|
assert.equal(segments[0].value, "1");
|
||||||
|
assert.equal(segments[1].type, "rooms");
|
||||||
|
assert.deepEqual(segments[1].value, [""]);
|
||||||
|
assert.equal(segments[2].type, "empty-grid-tile");
|
||||||
|
assert.equal(segments[2].value, 0);
|
||||||
|
},
|
||||||
|
"parse empty grid url with focus": assert => {
|
||||||
|
const segments = parseUrlPath("/session/1/rooms//1");
|
||||||
|
assert.equal(segments.length, 3);
|
||||||
|
assert.equal(segments[0].type, "session");
|
||||||
|
assert.equal(segments[0].value, "1");
|
||||||
|
assert.equal(segments[1].type, "rooms");
|
||||||
|
assert.deepEqual(segments[1].value, [""]);
|
||||||
|
assert.equal(segments[2].type, "empty-grid-tile");
|
||||||
|
assert.equal(segments[2].value, 1);
|
||||||
|
},
|
||||||
"parse open-room action replacing the current focused room": assert => {
|
"parse open-room action replacing the current focused room": assert => {
|
||||||
const nav = new Navigation(allowsChild);
|
const nav = new Navigation(allowsChild);
|
||||||
const path = nav.pathFrom([
|
const path = nav.pathFrom([
|
||||||
|
Loading…
Reference in New Issue
Block a user