File tree Expand file tree Collapse file tree 2 files changed +54
-3
lines changed Expand file tree Collapse file tree 2 files changed +54
-3
lines changed Original file line number Diff line number Diff line change @@ -76,8 +76,9 @@ export function createActionURL(
7676 const detectedHost = headers . get ( "x-forwarded-host" ) ?? headers . get ( "host" )
7777 const detectedProtocol =
7878 headers . get ( "x-forwarded-proto" ) ?? protocol ?? "https"
79-
80- url = new URL ( `${ detectedProtocol } ://${ detectedHost } ` )
79+ const _protocol = detectedProtocol . endsWith ( ":" ) ? detectedProtocol : detectedProtocol + ':'
80+
81+ url = new URL ( `${ _protocol } //${ detectedHost } ` )
8182 }
8283
8384 // remove trailing slash
Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ describe("config is inferred from environment variables", () => {
108108} )
109109
110110describe ( "createActionURL" , ( ) => {
111- const consoleWarnSpy = vi . spyOn ( console , "warn" ) . mockImplementation ( ( ) => { } )
111+ const consoleWarnSpy = vi . spyOn ( console , "warn" ) . mockImplementation ( ( ) => { } )
112112
113113 afterEach ( ( ) => {
114114 consoleWarnSpy . mockClear ( )
@@ -161,6 +161,56 @@ describe("createActionURL", () => {
161161 } ,
162162 expected : "https://example.com/auth/signin" ,
163163 } ,
164+ {
165+ args : {
166+ action : "signin" ,
167+ protocol : "http:" ,
168+ headers : new Headers ( {
169+ "x-forwarded-host" : "example.com" ,
170+ } ) ,
171+ env : { } ,
172+ basePath : "/auth" ,
173+ } ,
174+ expected : "http://example.com/auth/signin" ,
175+ } ,
176+ {
177+ args : {
178+ action : "signin" ,
179+ protocol : "https:" ,
180+ headers : new Headers ( {
181+ "x-forwarded-host" : "example.com" ,
182+ } ) ,
183+ env : { } ,
184+ basePath : "/auth" ,
185+ } ,
186+ expected : "https://example.com/auth/signin" ,
187+ } ,
188+ {
189+ args : {
190+ action : "signin" ,
191+ protocol : undefined ,
192+ headers : new Headers ( {
193+ "x-forwarded-host" : "example.com" ,
194+ "x-forwarded-proto" : "https" ,
195+ } ) ,
196+ env : { } ,
197+ basePath : "/auth" ,
198+ } ,
199+ expected : "https://example.com/auth/signin" ,
200+ } ,
201+ {
202+ args : {
203+ action : "signin" ,
204+ protocol : undefined ,
205+ headers : new Headers ( {
206+ "x-forwarded-host" : "example.com" ,
207+ "x-forwarded-proto" : "http" ,
208+ } ) ,
209+ env : { } ,
210+ basePath : "/auth" ,
211+ } ,
212+ expected : "http://example.com/auth/signin" ,
213+ } ,
164214 {
165215 args : {
166216 action : "signout" ,
You can’t perform that action at this time.
0 commit comments