File tree 2 files changed +28
-2
lines changed
2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,32 @@ describe("fastify createRequestHandler", () => {
66
66
expect ( response . body ) . toBe ( "URL: /foo/bar" ) ;
67
67
} ) ;
68
68
69
+ it ( "handles root // URLs" , async ( ) => {
70
+ mockedCreateRequestHandler . mockImplementation ( ( ) => async ( req ) => {
71
+ return new Response ( "URL: " + new URL ( req . url ) . pathname ) ;
72
+ } ) ;
73
+
74
+ let app = createApp ( ) ;
75
+
76
+ let response = await app . inject ( "//" ) ;
77
+
78
+ expect ( response . statusCode ) . toBe ( 200 ) ;
79
+ expect ( response . body ) . toBe ( "URL: //" ) ;
80
+ } ) ;
81
+
82
+ it ( "handles nested // URLs" , async ( ) => {
83
+ mockedCreateRequestHandler . mockImplementation ( ( ) => async ( req ) => {
84
+ return new Response ( "URL: " + new URL ( req . url ) . pathname ) ;
85
+ } ) ;
86
+
87
+ let app = createApp ( ) ;
88
+
89
+ let response = await app . inject ( "//foo//bar" ) ;
90
+
91
+ expect ( response . statusCode ) . toBe ( 200 ) ;
92
+ expect ( response . body ) . toBe ( "URL: //foo//bar" ) ;
93
+ } ) ;
94
+
69
95
it ( "handles null body" , async ( ) => {
70
96
mockedCreateRequestHandler . mockImplementation ( ( ) => async ( ) => {
71
97
return new Response ( null , { status : 200 } ) ;
Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ export function createRemixHeaders(
83
83
84
84
export function createRemixRequest ( request : FastifyRequest ) : NodeRequest {
85
85
let origin = `${ request . protocol } ://${ request . hostname } ` ;
86
- let url = new URL ( request . url , origin ) ;
86
+ let url = ` ${ origin } ${ request . url } ` ;
87
87
88
88
let controller = new AbortController ( ) ;
89
89
@@ -97,7 +97,7 @@ export function createRemixRequest(request: FastifyRequest): NodeRequest {
97
97
init . body = request . raw ;
98
98
}
99
99
100
- return new NodeRequest ( url . href , init ) ;
100
+ return new NodeRequest ( url , init ) ;
101
101
}
102
102
103
103
export async function sendRemixResponse (
You can’t perform that action at this time.
0 commit comments