File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -1922,9 +1922,15 @@ impl Url {
19221922 pub fn set_scheme ( & mut self , scheme : & str ) -> Result < ( ) , ( ) > {
19231923 let mut parser = Parser :: for_setter ( String :: new ( ) ) ;
19241924 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 ( ) ) {
19281934 return Err ( ( ) ) ;
19291935 }
19301936 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 {
138138 }
139139}
140140
141- #[ derive( Copy , Clone ) ]
141+ #[ derive( Copy , Clone , PartialEq ) ]
142142pub enum SchemeType {
143143 File ,
144144 SpecialNotFile ,
You can’t perform that action at this time.
0 commit comments