@@ -63,6 +63,10 @@ function isGoogleShortHost(hostname: string): boolean {
6363 return normalizeHost ( hostname ) === "maps.app.goo.gl" ;
6464}
6565
66+ function isGoogleConsentHost ( hostname : string ) : boolean {
67+ return normalizeHost ( hostname ) === "consent.google.com" ;
68+ }
69+
6670function providerFromHost ( hostname : string ) : ParsedSharedMapLink [ "provider" ] | null {
6771 const host = normalizeHost ( hostname ) ;
6872 if ( host === "maps.apple.com" ) return "apple" ;
@@ -345,6 +349,31 @@ export function isSupportedMapHost(url: URL): boolean {
345349 return false ;
346350}
347351
352+ function extractUrlFromGoogleConsent ( consentUrl : string ) : string | null {
353+ try {
354+ const parsed = new URL ( consentUrl ) ;
355+ if ( ! isGoogleConsentHost ( parsed . hostname ) ) return null ;
356+
357+ const continueParam = parsed . searchParams . get ( "continue" ) ;
358+ if ( ! continueParam ) return null ;
359+
360+ // Try to decode and validate the continue URL
361+ try {
362+ const decodedUrl = decodeURIComponent ( continueParam ) ;
363+ const continueUrlParsed = new URL ( decodedUrl ) ;
364+ if ( isSupportedMapHost ( continueUrlParsed ) ) {
365+ return decodedUrl ;
366+ }
367+ } catch {
368+ // If continue param isn't a valid URL, return null
369+ }
370+
371+ return null ;
372+ } catch {
373+ return null ;
374+ }
375+ }
376+
348377export function parseSharedMapCoordinates ( url : URL ) : { lat : number ; lon : number } | null {
349378 if ( ! isSupportedMapHost ( url ) ) return null ;
350379
@@ -417,6 +446,23 @@ export async function parseSharedMapLinkAsync(
417446 return null ;
418447 }
419448
449+ // Check if we got redirected to a consent page
450+ if ( isGoogleConsentHost ( expandedParsedUrl . hostname ) ) {
451+ console . info ( "[share.debug] consent_page_detected" ) ;
452+ const actualMapsUrl = extractUrlFromGoogleConsent ( expandedUrl ) ;
453+ if ( actualMapsUrl ) {
454+ console . info ( "[share.debug] extracted_from_consent" , actualMapsUrl ) ;
455+ const actualParsedUrl = parseUrl ( actualMapsUrl ) ;
456+ if ( actualParsedUrl ) {
457+ const parsedFromConsent = parseSharedMapLinkFromUrl ( actualParsedUrl , extracted ) ;
458+ if ( parsedFromConsent ) {
459+ console . info ( "[share.debug] parsed_from_consent_url" , parsedFromConsent ) ;
460+ return parsedFromConsent ;
461+ }
462+ }
463+ }
464+ }
465+
420466 const parsedExpandedLink = parseSharedMapLinkFromUrl ( expandedParsedUrl , extracted ) ;
421467 if ( parsedExpandedLink ) {
422468 console . info ( "[share.debug] parsed_from_expanded_url" , parsedExpandedLink ) ;
0 commit comments