File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -683,6 +683,43 @@ fn test_set_ip_host() {
683
683
assert_eq ! ( url. host_str( ) , Some ( "[::1]" ) ) ;
684
684
}
685
685
686
+ #[ test]
687
+ fn test_set_href ( ) {
688
+ use url:: quirks:: set_href;
689
+
690
+ let mut url = Url :: parse ( "https://existing.url" ) . unwrap ( ) ;
691
+
692
+ assert ! ( set_href( & mut url, "mal//formed" ) . is_err( ) ) ;
693
+
694
+ assert ! ( set_href(
695
+ & mut url,
696
+ "https://user:pass@domain.com:9742/path/file.ext?key=val&key2=val2#fragment"
697
+ )
698
+ . is_ok( ) ) ;
699
+ assert_eq ! (
700
+ url,
701
+ Url :: parse( "https://user:pass@domain.com:9742/path/file.ext?key=val&key2=val2#fragment" )
702
+ . unwrap( )
703
+ ) ;
704
+ }
705
+
706
+ #[ test]
707
+ fn test_domain_encoding_quirks ( ) {
708
+ use url:: quirks:: { domain_to_ascii, domain_to_unicode} ;
709
+
710
+ let data = [
711
+ ( "http://example.com" , "" , "" ) ,
712
+ ( "😅.🙂" , "xn--j28h.xn--938h" , "😅.🙂" ) ,
713
+ ( "example.com" , "example.com" , "example.com" ) ,
714
+ ( "mailto:test@example.net" , "" , "" ) ,
715
+ ] ;
716
+
717
+ for url in & data {
718
+ assert_eq ! ( domain_to_ascii( url. 0 ) , url. 1 ) ;
719
+ assert_eq ! ( domain_to_unicode( url. 0 ) , url. 2 ) ;
720
+ }
721
+ }
722
+
686
723
#[ test]
687
724
fn test_windows_unc_path ( ) {
688
725
if !cfg ! ( windows) {
You can’t perform that action at this time.
0 commit comments