diff --git a/src/bot/meetingUrlParser.ts b/src/bot/meetingUrlParser.ts index cd8e571..5d48313 100644 --- a/src/bot/meetingUrlParser.ts +++ b/src/bot/meetingUrlParser.ts @@ -72,7 +72,18 @@ export async function resolveLaunchUrl(meetingUrl: string, isAuthenticated: bool try { const response = await fetch(trimmed, { redirect: 'follow' }); - const resolvedUrl = new URL(response.url); + let resolvedUrlStr = response.url; + + // For authenticated joins: strip anon=true from everywhere in the URL + // Teams redirects embed anon=true in the inner url= parameter (URL-encoded) + if (isAuthenticated) { + resolvedUrlStr = resolvedUrlStr + .replace(/[&?]anon=true/gi, '') + .replace(/%26anon%3Dtrue/gi, '') + .replace(/%26anon%3Dfalse/gi, ''); + } + + const resolvedUrl = new URL(resolvedUrlStr); // Add params to suppress the native app launcher dialog resolvedUrl.searchParams.set('msLaunch', 'false'); @@ -84,6 +95,9 @@ export async function resolveLaunchUrl(meetingUrl: string, isAuthenticated: bool // Only add anon=true for anonymous joins if (!isAuthenticated) { resolvedUrl.searchParams.set('anon', 'true'); + } else { + // Ensure anon is removed from outer params too + resolvedUrl.searchParams.delete('anon'); } return resolvedUrl.toString();