@@ -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} ;
@@ -529,3 +529,21 @@ fn test_syntax_violation_callback_lifetimes() {
529
529
assert_eq ! ( url. path( ) , "/path" ) ;
530
530
assert_eq ! ( violation. take( ) , Some ( Backslash ) ) ;
531
531
}
532
+
533
+ #[ test]
534
+ fn test_options_reuse ( ) {
535
+ use url:: SyntaxViolation :: * ;
536
+ let violations = RefCell :: new ( Vec :: new ( ) ) ;
537
+
538
+ let options = Url :: options ( ) .
539
+ syntax_violation_callback ( Some ( |v| {
540
+ violations. borrow_mut ( ) . push ( v) ;
541
+ } ) ) ;
542
+ let url = options. parse ( "http:////mozilla.org" ) . unwrap ( ) ;
543
+
544
+ let options = options. base_url ( Some ( & url) ) ;
545
+ let url = options. parse ( "/sub\\ path" ) . unwrap ( ) ;
546
+ assert_eq ! ( url. as_str( ) , "http://mozilla.org/sub/path" ) ;
547
+ assert_eq ! ( * violations. borrow( ) ,
548
+ vec!( ExpectedDoubleSlash , Backslash ) ) ;
549
+ }
0 commit comments