Skip to content

Commit

Permalink
fix: encode URI components in google login url
Browse files Browse the repository at this point in the history
  • Loading branch information
scottydawg committed Sep 8, 2023
1 parent f77b320 commit 4cee80c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/react/src/GoogleLoginButton/GoogleLoginButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ export default function GoogleSSOButton(props: {
}) {
const { workspace, database, newTenantName } = props;
const { basePath } = useNileConfig();
// workspace and database can be `''`.
// let this fail silently for now, and update the context when the time comes
const contextHref = `${basePath}/workspaces/${workspace}/databases/${database}/${LOGIN_PATH}`;
const query = newTenantName ? '?newTenant=' + newTenantName : '';
const encodedWorkspace = encodeURIComponent(workspace ?? '');
const encodedDatabase = encodeURIComponent(database ?? '');
const contextHref = `${basePath}/workspaces/${encodedWorkspace}/databases/${encodedDatabase}/${LOGIN_PATH}`;
const query = newTenantName
? '?newTenant=' + encodeURIComponent(newTenantName)
: '';
const href = (props?.href ?? contextHref) + query;
return (
<Box
Expand Down

0 comments on commit 4cee80c

Please sign in to comment.