From 2b1664601922bd1f0531b919c1d2a89170e1b182 Mon Sep 17 00:00:00 2001 From: Dawson Toth Date: Tue, 26 May 2026 10:54:26 -0400 Subject: [PATCH 1/2] fix: Detect and omit oauth prefix from path parts --- src/lib/resource.ts | 7 ++++++- test/lib/OAuthResource.helpers.test.js | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/lib/resource.ts b/src/lib/resource.ts index be3537e..2f3aa16 100644 --- a/src/lib/resource.ts +++ b/src/lib/resource.ts @@ -77,7 +77,12 @@ export class OAuthResource extends Resource { }; } - const pathParts = path.split('/').filter((p) => p); + let pathParts = path.split('/').filter((p) => p); + + // Handle /oauth prefix if present + if (pathParts[0] === 'oauth' && pathParts.length > 1) { + pathParts = pathParts.slice(1); + } return { providerName: pathParts[0] || '', diff --git a/test/lib/OAuthResource.helpers.test.js b/test/lib/OAuthResource.helpers.test.js index c8601ca..058858e 100644 --- a/test/lib/OAuthResource.helpers.test.js +++ b/test/lib/OAuthResource.helpers.test.js @@ -86,6 +86,22 @@ describe('OAuthResource - Helper Methods', () => { assert.equal(route.providerName, 'github'); assert.equal(route.action, 'login'); }); + + it('should handle /oauth prefix', () => { + const target = { id: '/oauth/github/login', pathname: '' }; + const route = OAuthResource.parseRoute(target); + + assert.equal(route.providerName, 'github'); + assert.equal(route.action, 'login'); + }); + + it('should handle /oauth prefix with tenant ID', () => { + const target = { id: '/oauth/oac-abc123/login', pathname: '' }; + const route = OAuthResource.parseRoute(target); + + assert.equal(route.providerName, 'oac-abc123'); + assert.equal(route.action, 'login'); + }); }); describe('isDebugOnlyRoute()', () => { From ca44645d33121fdafd5b2b7dfc2b0aca44fc135f Mon Sep 17 00:00:00 2001 From: Dawson Toth Date: Tue, 26 May 2026 11:08:30 -0400 Subject: [PATCH 2/2] fix: Handle top-level oauth list request --- src/lib/resource.ts | 4 ++-- test/lib/OAuthResource.helpers.test.js | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/lib/resource.ts b/src/lib/resource.ts index 2f3aa16..dc07cb0 100644 --- a/src/lib/resource.ts +++ b/src/lib/resource.ts @@ -79,8 +79,8 @@ export class OAuthResource extends Resource { let pathParts = path.split('/').filter((p) => p); - // Handle /oauth prefix if present - if (pathParts[0] === 'oauth' && pathParts.length > 1) { + // Handle /oauth prefix if present (case-insensitive) + if (pathParts[0]?.toLowerCase() === 'oauth') { pathParts = pathParts.slice(1); } diff --git a/test/lib/OAuthResource.helpers.test.js b/test/lib/OAuthResource.helpers.test.js index 058858e..4e1ee52 100644 --- a/test/lib/OAuthResource.helpers.test.js +++ b/test/lib/OAuthResource.helpers.test.js @@ -102,6 +102,22 @@ describe('OAuthResource - Helper Methods', () => { assert.equal(route.providerName, 'oac-abc123'); assert.equal(route.action, 'login'); }); + + it('should handle /oauth prefix only', () => { + const target = { id: '/oauth', pathname: '' }; + const route = OAuthResource.parseRoute(target); + + assert.equal(route.providerName, ''); + assert.equal(route.action, ''); + }); + + it('should handle case-insensitive /Oauth prefix', () => { + const target = { id: '/Oauth/github/login', pathname: '' }; + const route = OAuthResource.parseRoute(target); + + assert.equal(route.providerName, 'github'); + assert.equal(route.action, 'login'); + }); }); describe('isDebugOnlyRoute()', () => {