diff --git a/packages/authentication-oauth/src/strategy.ts b/packages/authentication-oauth/src/strategy.ts index e9f2bb77c0..4bfe2589fc 100644 --- a/packages/authentication-oauth/src/strategy.ts +++ b/packages/authentication-oauth/src/strategy.ts @@ -96,7 +96,7 @@ export class OAuthStrategy extends AuthenticationBaseStrategy { } const redirectUrl = `${redirect}${queryRedirect}` - const separator = redirect.endsWith('?') ? '' : redirect.indexOf('#') !== -1 ? '?' : '#' + const separator = redirectUrl.endsWith('?') ? '' : redirect.indexOf('#') !== -1 ? '?' : '#' const authResult: AuthenticationResult = data const query = authResult.accessToken ? { access_token: authResult.accessToken } diff --git a/packages/authentication-oauth/test/strategy.test.ts b/packages/authentication-oauth/test/strategy.test.ts index 50e9b27671..a4386fcbc2 100644 --- a/packages/authentication-oauth/test/strategy.test.ts +++ b/packages/authentication-oauth/test/strategy.test.ts @@ -43,6 +43,14 @@ describe('@feathersjs/authentication-oauth/strategy', () => { ) assert.strictEqual('/home/hi-there#access_token=testing', redirect) + redirect = await strategy.getRedirect( + { accessToken: 'testing' }, + { + redirect: '/hi-there?' + } + ) + assert.equal(redirect, '/home/hi-there?access_token=testing') + redirect = await strategy.getRedirect(new Error('something went wrong')) assert.equal(redirect, '/home#error=something%20went%20wrong')