@@ -13,7 +13,7 @@ extern crate url;
13
13
14
14
use std:: ascii:: AsciiExt ;
15
15
use std:: borrow:: Cow ;
16
- use std:: cell:: Cell ;
16
+ use std:: cell:: { Cell , RefCell } ;
17
17
use std:: net:: { Ipv4Addr , Ipv6Addr } ;
18
18
use std:: path:: { Path , PathBuf } ;
19
19
use url:: { Host , HostAndPort , Url , form_urlencoded} ;
@@ -526,3 +526,20 @@ fn test_syntax_violation_callback_lifetimes() {
526
526
assert_eq ! ( url. path( ) , "/path" ) ;
527
527
assert_eq ! ( violation. take( ) , Some ( Backslash ) ) ;
528
528
}
529
+
530
+ #[ test]
531
+ fn test_options_reuse ( ) {
532
+ use url:: SyntaxViolation :: * ;
533
+ let violations = RefCell :: new ( Vec :: new ( ) ) ;
534
+ let vfn = |v| violations. borrow_mut ( ) . push ( v) ;
535
+
536
+ let options = Url :: options ( ) .
537
+ syntax_violation_callback ( Some ( & vfn) ) ;
538
+ let url = options. parse ( "http:////mozilla.org" ) . unwrap ( ) ;
539
+
540
+ let options = options. base_url ( Some ( & url) ) ;
541
+ let url = options. parse ( "/sub\\ path" ) . unwrap ( ) ;
542
+ assert_eq ! ( url. as_str( ) , "http://mozilla.org/sub/path" ) ;
543
+ assert_eq ! ( * violations. borrow( ) ,
544
+ vec!( ExpectedDoubleSlash , Backslash ) ) ;
545
+ }
0 commit comments