From 4cee80c9ab20ab2d1d853568d3aa1c7bc40a4ebc Mon Sep 17 00:00:00 2001 From: Scott Delamater <923236+scottydawg@users.noreply.github.com> Date: Fri, 8 Sep 2023 11:58:27 -0400 Subject: [PATCH] fix: encode URI components in google login url --- .../react/src/GoogleLoginButton/GoogleLoginButton.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/react/src/GoogleLoginButton/GoogleLoginButton.tsx b/packages/react/src/GoogleLoginButton/GoogleLoginButton.tsx index ee03dca3..b32a5f17 100644 --- a/packages/react/src/GoogleLoginButton/GoogleLoginButton.tsx +++ b/packages/react/src/GoogleLoginButton/GoogleLoginButton.tsx @@ -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 (