From d0064ca30005ac06dd3423a9b110c56b5bef3381 Mon Sep 17 00:00:00 2001 From: EgorT Date: Fri, 9 May 2025 14:21:19 +0200 Subject: [PATCH 1/4] Fix undefined providerId Client-side auth with no `providerId` param results in error. --- packages/core/src/lib/utils/web.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/core/src/lib/utils/web.ts b/packages/core/src/lib/utils/web.ts index 9e782978bb..1361a4ed8d 100644 --- a/packages/core/src/lib/utils/web.ts +++ b/packages/core/src/lib/utils/web.ts @@ -144,5 +144,8 @@ export function parseActionAndProviderId( ) throw new UnknownAction(`Cannot parse action at ${pathname}`) - return { action, providerId } + return { + action, + providerId: providerId == "undefined" ? undefined : providerId + } } From f10711442129fb0a35c18b8dd65064cfee4666c2 Mon Sep 17 00:00:00 2001 From: EgorT Date: Mon, 12 May 2025 12:43:00 +0200 Subject: [PATCH 2/4] dev: Add test for 'undefined' provider url-parsing.test.ts --- packages/core/test/url-parsing.test.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/core/test/url-parsing.test.ts b/packages/core/test/url-parsing.test.ts index 330b6384f0..91b215a591 100644 --- a/packages/core/test/url-parsing.test.ts +++ b/packages/core/test/url-parsing.test.ts @@ -82,3 +82,11 @@ describe("parse the action and provider id", () => { } }) }) + +it("should return undefined for providerId if it is empty", () => { + const path = "/auth/signin/undefined"; + const basePath = "/auth"; + const parsed = parseActionAndProviderId(path, basePath); + expect(parsed.action).toBe("signin"); + expect(parsed.providerId).toBeUndefined(); +}); From dc95ad0fcd75a19fb0b1f03f9f30984a791703ed Mon Sep 17 00:00:00 2001 From: Thang Vu Date: Tue, 13 May 2025 08:37:43 +0700 Subject: [PATCH 3/4] simplify tests --- packages/core/test/url-parsing.test.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/core/test/url-parsing.test.ts b/packages/core/test/url-parsing.test.ts index 91b215a591..d978b37fe7 100644 --- a/packages/core/test/url-parsing.test.ts +++ b/packages/core/test/url-parsing.test.ts @@ -70,6 +70,12 @@ describe("parse the action and provider id", () => { providerId: "auth0", basePath: "/auth", }, + { + path: "/auth/signin/undefined", + action: "signin", + providerId: undefined, + basePath: "/auth", + }, ])("$path", ({ path, error, basePath, action, providerId }) => { if (action || providerId) { const parsed = parseActionAndProviderId(path, basePath) @@ -82,11 +88,3 @@ describe("parse the action and provider id", () => { } }) }) - -it("should return undefined for providerId if it is empty", () => { - const path = "/auth/signin/undefined"; - const basePath = "/auth"; - const parsed = parseActionAndProviderId(path, basePath); - expect(parsed.action).toBe("signin"); - expect(parsed.providerId).toBeUndefined(); -}); From bd61b6d969aef9419e3be3ee4c05601cc698cce0 Mon Sep 17 00:00:00 2001 From: Thang Vu Date: Tue, 13 May 2025 09:08:08 +0700 Subject: [PATCH 4/4] formatting --- packages/core/src/lib/utils/web.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/core/src/lib/utils/web.ts b/packages/core/src/lib/utils/web.ts index 1361a4ed8d..fdbafbcadc 100644 --- a/packages/core/src/lib/utils/web.ts +++ b/packages/core/src/lib/utils/web.ts @@ -144,8 +144,8 @@ export function parseActionAndProviderId( ) throw new UnknownAction(`Cannot parse action at ${pathname}`) - return { - action, - providerId: providerId == "undefined" ? undefined : providerId + return { + action, + providerId: providerId == "undefined" ? undefined : providerId, } }