@@ -86,23 +86,26 @@ export function expectedRouteAuthRedirectUris(routeLabels: string[]): string[] {
8686
8787 const route = label . slice ( 0 , authIndex ) ;
8888 const suffix = label . slice ( authIndex ) ;
89- if ( ! / ^ @ a u t h (?: : [ A - Z a - z 0 - 9 . _ , - ] + ) ? $ / . test ( suffix ) ) {
89+ if ( ! / ^ @ a u t h (?: : [ A - Z a - z 0 - 9 . _ , - ] + ) ? (?: ~ [ A - Z a - z 0 - 9 . - ] + ) ? $ / . test ( suffix ) ) {
9090 throw new Error ( `unsupported auth suffix: ${ suffix } ` ) ;
9191 }
9292
9393 const parsed = new URL ( route ) ;
94+ const callbackIndex = suffix . indexOf ( "~" ) ;
95+ const policySuffix = callbackIndex === - 1 ? suffix : suffix . slice ( 0 , callbackIndex ) ;
96+ const callbackHost = callbackIndex === - 1 ? parsed . hostname : suffix . slice ( callbackIndex + 1 ) ;
9497 const groups = [
9598 ...new Set (
96- suffix . includes ( ":" )
97- ? suffix
98- . slice ( suffix . indexOf ( ":" ) + 1 )
99+ policySuffix . includes ( ":" )
100+ ? policySuffix
101+ . slice ( policySuffix . indexOf ( ":" ) + 1 )
99102 . split ( "," )
100103 . map ( ( group ) => group . trim ( ) )
101104 . filter ( Boolean )
102105 : [ ]
103106 )
104107 ] . sort ( ) ;
105- const key = `${ parsed . hostname } \n${ groups . join ( "\n" ) } ` ;
108+ const key = `${ parsed . hostname } \n${ callbackHost } \n ${ groups . join ( "\n" ) } ` ;
106109 if ( profiles . has ( key ) ) {
107110 continue ;
108111 }
@@ -112,7 +115,7 @@ export function expectedRouteAuthRedirectUris(routeLabels: string[]): string[] {
112115 const base = slugify ( `${ parsed . hostname } -${ policy } ` ) ;
113116 const trimmed = base . length > 56 ? base . slice ( 0 , 56 ) . replace ( / - + $ / g, "" ) : base ;
114117 const hash = createHash ( "sha256" ) . update ( key ) . digest ( "hex" ) . slice ( 0 , 10 ) ;
115- redirectUris . push ( `https://${ parsed . hostname } /oauth2/route/${ trimmed || "route" } -${ hash } /callback` ) ;
118+ redirectUris . push ( `https://${ callbackHost } /oauth2/route/${ trimmed || "route" } -${ hash } /callback` ) ;
116119 }
117120 return redirectUris . sort ( ) ;
118121}
0 commit comments