@@ -71,28 +71,33 @@ test("isDomainMatch", () => {
7171
7272test ( "getRelativeUrl" , ( ) => {
7373 // Helper to create a mock Context
74- const createMockContext = ( url : string , headers : Record < string , string > = { } ) => {
74+ const createMockContext = (
75+ url : string ,
76+ headers : Record < string , string > = { } ,
77+ ) => {
7578 return {
7679 req : {
7780 url,
78- header : ( name : string ) => headers [ name . toLowerCase ( ) ] || '' ,
81+ header : ( name : string ) => headers [ name . toLowerCase ( ) ] || "" ,
7982 } ,
80- } as Context ;
81- } ;
83+ } as Context
84+ }
8285
8386 // Test basic URL construction
84- const ctx1 = createMockContext ( ' http://example.com' ) ;
85- expect ( getRelativeUrl ( ctx1 , ' /path' ) ) . toBe ( ' http://example.com/path' ) ;
86-
87+ const ctx1 = createMockContext ( " http://example.com" )
88+ expect ( getRelativeUrl ( ctx1 , " /path" ) ) . toBe ( " http://example.com/path" )
89+
8790 // Test with x-forwarded headers
88- const ctx2 = createMockContext ( ' http://original.com' , {
89- ' x-forwarded-host' : ' forwarded.com' ,
90- ' x-forwarded-proto' : ' https' ,
91- ' x-forwarded-port' : ' 443'
92- } ) ;
93- expect ( getRelativeUrl ( ctx2 , ' /path' ) ) . toBe ( ' https://forwarded.com/path' ) ;
91+ const ctx2 = createMockContext ( " http://original.com" , {
92+ " x-forwarded-host" : " forwarded.com" ,
93+ " x-forwarded-proto" : " https" ,
94+ " x-forwarded-port" : " 443" ,
95+ } )
96+ expect ( getRelativeUrl ( ctx2 , " /path" ) ) . toBe ( " https://forwarded.com/path" )
9497
9598 // Test with absolute URLs
96- const ctx4 = createMockContext ( 'http://example.com' ) ;
97- expect ( getRelativeUrl ( ctx4 , 'http://other.com/path' ) ) . toBe ( 'http://other.com/path' ) ;
98- } ) ;
99+ const ctx4 = createMockContext ( "http://example.com" )
100+ expect ( getRelativeUrl ( ctx4 , "http://other.com/path" ) ) . toBe (
101+ "http://other.com/path" ,
102+ )
103+ } )
0 commit comments