From d9c8a6339e0e939179da067ccdb742d754fca204 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 13 Oct 2020 13:13:35 +0200 Subject: [PATCH] support empty strings for rooms segment --- src/domain/navigation/index.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/domain/navigation/index.js b/src/domain/navigation/index.js index eca2c95f..a1e65d4c 100644 --- a/src/domain/navigation/index.js +++ b/src/domain/navigation/index.js @@ -69,7 +69,7 @@ export function parseUrlPath(urlPath, currentNavPath) { const type = next.value; if (type === "rooms") { const roomsValue = iterator.next().value; - if (!roomsValue) { break; } + if (roomsValue === undefined) { break; } const roomIds = roomsValue.split(","); segments.push(new Segment(type, roomIds)); 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].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 => { const nav = new Navigation(allowsChild); const path = nav.pathFrom([