From f2774512c3e748d1d4cb8740a3b6f0143e4a8ef8 Mon Sep 17 00:00:00 2001 From: Baptiste Rios Campo Date: Mon, 25 Apr 2022 14:21:42 +0200 Subject: [PATCH 1/2] [Fix] calling navigate with number throws - the function `startsWith` was called in any case and was causing an exception to throw when passing `number` --- src/lib/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/utils.js b/src/lib/utils.js index dd2c760a..d468eb73 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -142,7 +142,7 @@ let match = (path, uri) => pick([{ path }], uri); // require less contextual information and (fingers crossed) be more intuitive. let resolve = (to, base) => { // /foo/bar, /baz/qux => /foo/bar - if (startsWith(to, "/")) { + if (typeof to === "number" || startsWith(to, "/")) { return to; } From 142dab5409c4556db883ecf65e5db7211c8c6c4e Mon Sep 17 00:00:00 2001 From: Baptiste Rios Campo Date: Mon, 25 Apr 2022 14:36:08 +0200 Subject: [PATCH 2/2] fix: add a test for this case --- src/lib/utils.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/utils.test.js b/src/lib/utils.test.js index b34deb29..08051119 100644 --- a/src/lib/utils.test.js +++ b/src/lib/utils.test.js @@ -84,6 +84,7 @@ describe("resolve", () => { expect(resolve("/groups?some=query", "/users?some=thing")).toEqual( "/groups?some=query" ); + expect(resolve(-1)).toEqual(-1); }); });