File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -644,6 +644,11 @@ fn to_str(url: url) -> ~str {
644
644
} else {
645
645
~""
646
646
} ;
647
+ let authority = if str:: len ( url. host ) != 0 {
648
+ str:: concat ( ~[ ~"//", user, copy url. host ] )
649
+ } else {
650
+ ~""
651
+ } ;
647
652
let query = if url. query . len ( ) == 0 {
648
653
~""
649
654
} else {
@@ -657,12 +662,11 @@ fn to_str(url: url) -> ~str {
657
662
} ;
658
663
659
664
return str:: concat ( ~[ copy url. scheme ,
660
- ~": //",
661
- user,
662
- copy url. host ,
663
- copy url. path ,
664
- query,
665
- fragment] ) ;
665
+ ~": ",
666
+ authority,
667
+ copy url. path ,
668
+ query,
669
+ fragment] ) ;
666
670
}
667
671
668
672
impl of to_str:: to_str for url {
@@ -849,6 +853,12 @@ mod tests {
849
853
.get().second() == ~" #& +";
850
854
}
851
855
856
+ #[test]
857
+ fn test_url_without_authority() {
858
+ let url = ~" mailto: test@email. com";
859
+ assert to_str ( result:: unwrap ( from_str ( url) ) ) == url;
860
+ }
861
+
852
862
#[ test]
853
863
fn test_encode( ) {
854
864
assert encode ( ~"") == ~"";
You can’t perform that action at this time.
0 commit comments