@@ -504,16 +504,46 @@ impl std::fmt::Debug for Url {
504504 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
505505 unsafe {
506506 let components = ffi:: ada_get_components ( self . url ) . as_ref ( ) . unwrap ( ) ;
507- f. debug_struct ( "Url" )
507+
508+ let mut debug = f. debug_struct ( "Url" ) ;
509+
510+ debug
508511 . field ( "href" , & self . href ( ) )
509512 . field ( "protocol_end" , & components. protocol_end )
510- . field ( "username_end" , & components. username_end )
511513 . field ( "host_start" , & components. host_start )
512- . field ( "host_end" , & components. host_end )
513- . field ( "port" , & components. port )
514- . field ( "pathname_start" , & components. pathname_start )
515- . field ( "search_start" , & components. search_start )
516- . field ( "hash_start" , & components. hash_start )
514+ . field ( "host_end" , & components. host_end ) ;
515+ let port = if components. port == u32:: MAX {
516+ Some ( components. port )
517+ } else {
518+ None
519+ } ;
520+ let username_end = if components. username_end == u32:: MAX {
521+ None
522+ } else {
523+ Some ( components. username_end )
524+ } ;
525+ let search_start = if components. search_start == u32:: MAX {
526+ None
527+ } else {
528+ Some ( components. search_start )
529+ } ;
530+ let hash_start = if components. hash_start == u32:: MAX {
531+ None
532+ } else {
533+ Some ( components. hash_start )
534+ } ;
535+ let pathname_start = if components. pathname_start == u32:: MAX {
536+ None
537+ } else {
538+ Some ( components. pathname_start )
539+ } ;
540+
541+ debug
542+ . field ( "port" , & port)
543+ . field ( "username_end" , & username_end)
544+ . field ( "search_start" , & search_start)
545+ . field ( "hash_start" , & hash_start)
546+ . field ( "pathname_start" , & pathname_start)
517547 . finish ( )
518548 }
519549 }
0 commit comments