File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -101,13 +101,13 @@ impl<'a> OmaSourceEntry<'a> {
101
101
102
102
pub fn from ( & self ) -> Result < & OmaSourceEntryFrom , RefreshError > {
103
103
self . from . get_or_try_init ( || {
104
- let url = self . source . url ( ) ;
105
- if url. starts_with ( "http" ) {
106
- Ok ( OmaSourceEntryFrom :: Http )
107
- } else if url. starts_with ( "file" ) {
108
- Ok ( OmaSourceEntryFrom :: Local )
109
- } else {
110
- return Err ( RefreshError :: UnsupportedProtocol ( url . to_string ( ) ) ) ;
104
+ let url = Url :: parse ( self . url ( ) )
105
+ . map_err ( |_| RefreshError :: InvalidUrl ( self . url ( ) . to_string ( ) ) ) ? ;
106
+
107
+ match url. scheme ( ) {
108
+ "file" => Ok ( OmaSourceEntryFrom :: Local ) ,
109
+ "http" | "https" => Ok ( OmaSourceEntryFrom :: Http ) ,
110
+ x => Err ( RefreshError :: UnsupportedProtocol ( x . to_string ( ) ) ) ,
111
111
}
112
112
} )
113
113
}
You can’t perform that action at this time.
0 commit comments