From eb9719467f7c143a26bfd2d598b3903ff0815731 Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Mon, 10 Aug 2020 11:55:37 -0700 Subject: [PATCH] fix(@aws-amplify/auth): Default hash to `#` when null (#6279) --- packages/auth/src/OAuth/OAuth.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/auth/src/OAuth/OAuth.ts b/packages/auth/src/OAuth/OAuth.ts index 96159e11998..7b61bd0417e 100644 --- a/packages/auth/src/OAuth/OAuth.ts +++ b/packages/auth/src/OAuth/OAuth.ts @@ -183,8 +183,9 @@ export default class OAuth { } private async _handleImplicitFlow(currentUrl: string) { - const { id_token, access_token } = parse(currentUrl) - .hash.substr(1) // Remove # from returned code + // hash is `null` if `#` doesn't exist on URL + const { id_token, access_token } = (parse(currentUrl).hash || '#') + .substr(1) // Remove # from returned code .split('&') .map(pairings => pairings.split('=')) .reduce((accum, [k, v]) => ({ ...accum, [k]: v }), {