@@ -8,7 +8,6 @@ use rust_i18n::t;
88use serde_json:: Value ;
99use super :: Function ;
1010use url:: Url ;
11- use std:: net:: Ipv6Addr ;
1211
1312#[ derive( Debug , Default ) ]
1413pub struct Uri { }
@@ -52,21 +51,7 @@ impl Function for Uri {
5251 let result = base. join ( relative_uri)
5352 . map_err ( |e| DscError :: Parser ( format ! ( "{}: {}" , t!( "functions.uri.invalidRelativeUri" ) , e) ) ) ?;
5453
55- let final_result = if let Some ( url:: Host :: Ipv6 ( ipv6_addr) ) = result. host ( ) {
56- let segments = ipv6_addr. segments ( ) ;
57- let expanded = format ! ( "{:04X}:{:04X}:{:04X}:{:04X}:{:04X}:{:04X}:{:04X}:{:04X}" ,
58- segments[ 0 ] , segments[ 1 ] , segments[ 2 ] , segments[ 3 ] ,
59- segments[ 4 ] , segments[ 5 ] , segments[ 6 ] , segments[ 7 ]
60- ) ;
61-
62- let addr = Ipv6Addr :: from ( segments) ;
63- let compressed = addr. to_string ( ) ;
64- result. to_string ( ) . replace ( & compressed, & expanded)
65- } else {
66- result. to_string ( )
67- } ;
68-
69- Ok ( Value :: String ( final_result) )
54+ Ok ( Value :: String ( result. to_string ( ) ) )
7055 }
7156}
7257
@@ -228,23 +213,23 @@ mod tests {
228213 fn test_uri_ipv6_localhost ( ) {
229214 let mut parser = Statement :: new ( ) . unwrap ( ) ;
230215 let result = parser. parse_and_execute ( "[uri('https://[::1]/', 'path')]" , & Context :: new ( ) ) . unwrap ( ) ;
231- // IPv6 should be expanded to match .NET behavior
232- assert_eq ! ( result, "https://[0000:0000:0000:0000:0000:0000:0000:0001 ]/path" ) ;
216+ // IPv6 uses compressed format (standard representation)
217+ assert_eq ! ( result, "https://[::1 ]/path" ) ;
233218 }
234219
235220 #[ test]
236221 fn test_uri_ipv6_address ( ) {
237222 let mut parser = Statement :: new ( ) . unwrap ( ) ;
238223 let result = parser. parse_and_execute ( "[uri('https://[2001:db8::1]/', 'api/v1')]" , & Context :: new ( ) ) . unwrap ( ) ;
239- // IPv6 should be expanded to match .NET behavior
240- assert_eq ! ( result, "https://[2001:0DB8:0000:0000:0000:0000:0000:0001 ]/api/v1" ) ;
224+ // IPv6 uses compressed format (standard representation)
225+ assert_eq ! ( result, "https://[2001:db8::1 ]/api/v1" ) ;
241226 }
242227
243228 #[ test]
244229 fn test_uri_ipv6_with_port ( ) {
245230 let mut parser = Statement :: new ( ) . unwrap ( ) ;
246231 let result = parser. parse_and_execute ( "[uri('https://[2001:db8::1]:8080/', 'api')]" , & Context :: new ( ) ) . unwrap ( ) ;
247- assert_eq ! ( result, "https://[2001:0DB8:0000:0000:0000:0000:0000:0001 ]:8080/api" ) ;
232+ assert_eq ! ( result, "https://[2001:db8::1 ]:8080/api" ) ;
248233 }
249234
250235 #[ test]
0 commit comments