File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -91,13 +91,17 @@ function shouldUseSecureCookies(): boolean {
9191 return ! ( isLocalhost && appOrigin . protocol === "http:" ) ;
9292}
9393
94- function normalizeOrigin ( value : string ) : string {
94+ function normalizeOrigin ( value : string ) : string | null {
9595 const trimmed = value . trim ( ) . replace ( TRAILING_SLASHES_REGEX , "" ) ;
9696
97+ if ( ! trimmed ) {
98+ return null ;
99+ }
100+
97101 try {
98102 return new URL ( trimmed ) . origin ;
99103 } catch {
100- return trimmed ;
104+ return null ;
101105 }
102106}
103107
@@ -112,13 +116,15 @@ function getTrustedOrigins(): string[] {
112116 isProduction ( ) ? undefined : "http://localhost:3001" ,
113117 ]
114118 . filter ( ( value ) : value is string => Boolean ( value ) )
115- . map ( normalizeOrigin ) ;
119+ . map ( normalizeOrigin )
120+ . filter ( ( origin ) : origin is string => Boolean ( origin ) ) ;
116121
117122 const extraOrigins = ( process . env . AUTH_TRUSTED_ORIGINS ?? "" )
118123 . split ( "," )
119124 . map ( ( origin ) => origin . trim ( ) )
120125 . filter ( Boolean )
121- . map ( normalizeOrigin ) ;
126+ . map ( normalizeOrigin )
127+ . filter ( ( origin ) : origin is string => Boolean ( origin ) ) ;
122128
123129 return [ ...new Set ( [ ...defaults , ...extraOrigins ] ) ] ;
124130}
You can’t perform that action at this time.
0 commit comments