File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ base64.workspace = true
1818bytes.workspace = true
1919data-url.workspace = true
2020deno_core.workspace = true
21+ deno_path_util.workspace = true
2122deno_permissions.workspace = true
2223deno_tls.workspace = true
2324dyn-clone = " 1"
Original file line number Diff line number Diff line change @@ -41,6 +41,8 @@ use deno_core::OpState;
4141use deno_core:: RcRef ;
4242use deno_core:: Resource ;
4343use deno_core:: ResourceId ;
44+ use deno_path_util:: url_from_file_path;
45+ use deno_path_util:: PathToUrlError ;
4446use deno_permissions:: PermissionCheckError ;
4547use deno_tls:: rustls:: RootCertStore ;
4648use deno_tls:: Proxy ;
@@ -172,6 +174,8 @@ pub enum FetchError {
172174 NetworkError ,
173175 #[ error( "Fetching files only supports the GET method: received {0}" ) ]
174176 FsNotGet ( Method ) ,
177+ #[ error( transparent) ]
178+ PathToUrl ( #[ from] PathToUrlError ) ,
175179 #[ error( "Invalid URL {0}" ) ]
176180 InvalidUrl ( Url ) ,
177181 #[ error( transparent) ]
@@ -436,7 +440,7 @@ where
436440 let permissions = state. borrow_mut :: < FP > ( ) ;
437441 let path = permissions. check_read ( & path, "fetch()" ) ?;
438442 let url = match path {
439- Cow :: Owned ( path) => Url :: from_file_path ( path) . unwrap ( ) ,
443+ Cow :: Owned ( path) => url_from_file_path ( & path) ? ,
440444 Cow :: Borrowed ( _) => url,
441445 } ;
442446
Original file line number Diff line number Diff line change @@ -696,6 +696,7 @@ fn get_fetch_error(error: &FetchError) -> &'static str {
696696 FetchError :: Permission ( e) => get_permission_check_error_class ( e) ,
697697 FetchError :: NetworkError => "TypeError" ,
698698 FetchError :: FsNotGet ( _) => "TypeError" ,
699+ FetchError :: PathToUrl ( _) => "TypeError" ,
699700 FetchError :: InvalidUrl ( _) => "TypeError" ,
700701 FetchError :: InvalidHeaderName ( _) => "TypeError" ,
701702 FetchError :: InvalidHeaderValue ( _) => "TypeError" ,
You can’t perform that action at this time.
0 commit comments