refactor(ui): guard buildOnboardingUrl against a missing invitation id

Return "" instead of emitting an invitation_id=undefined link when the id is not yet available, matching the existing empty-baseUrl guard. Placed after the SSO branch so the SSO link, which does not use the id, is unaffected

Refs LIT-3687
This commit is contained in:
ryan-crabbe-berri 2026-06-20 11:05:22 -07:00
parent c7a5e211c8
commit 82ca9a2a60
2 changed files with 14 additions and 0 deletions

View file

@ -56,4 +56,15 @@ describe("buildOnboardingUrl", () => {
}),
).toBe("");
});
it("returns an empty string rather than an invitation_id=undefined link when the id is not ready", () => {
expect(
buildOnboardingUrl({
baseUrl: "http://localhost:4000/",
invitationId: undefined,
hasUserSetupSso: false,
resetPassword: false,
}),
).toBe("");
});
});

View file

@ -44,6 +44,9 @@ export function buildOnboardingUrl({
if (hasUserSetupSso) {
return new URL(uiPath, baseUrl).toString();
}
if (!invitationId) {
return "";
}
const action = resetPassword ? "&action=reset_password" : "";
return new URL(`${uiPath}/onboarding?invitation_id=${invitationId}${action}`, baseUrl).toString();
}