File tree 2 files changed +10
-4
lines changed
2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -1922,9 +1922,15 @@ impl Url {
1922
1922
pub fn set_scheme ( & mut self , scheme : & str ) -> Result < ( ) , ( ) > {
1923
1923
let mut parser = Parser :: for_setter ( String :: new ( ) ) ;
1924
1924
let remaining = parser. parse_scheme ( parser:: Input :: new ( scheme) ) ?;
1925
- if !remaining. is_empty ( )
1926
- || ( !self . has_host ( ) && SchemeType :: from ( & parser. serialization ) . is_special ( ) )
1927
- {
1925
+ let new_scheme_type = SchemeType :: from ( & parser. serialization ) ;
1926
+ let old_scheme_type = SchemeType :: from ( self . scheme ( ) ) ;
1927
+ // Switching from special scheme to non special scheme
1928
+ // and switching from file to non file is not allowed
1929
+ if old_scheme_type != new_scheme_type {
1930
+ return Err ( ( ) ) ;
1931
+ }
1932
+
1933
+ if !remaining. is_empty ( ) || ( !self . has_host ( ) && new_scheme_type. is_special ( ) ) {
1928
1934
return Err ( ( ) ) ;
1929
1935
}
1930
1936
let old_scheme_end = self . scheme_end ;
Original file line number Diff line number Diff line change @@ -138,7 +138,7 @@ impl fmt::Display for SyntaxViolation {
138
138
}
139
139
}
140
140
141
- #[ derive( Copy , Clone ) ]
141
+ #[ derive( Copy , Clone , PartialEq ) ]
142
142
pub enum SchemeType {
143
143
File ,
144
144
SpecialNotFile ,
You can’t perform that action at this time.
0 commit comments