File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
src/wasm_navdata_interface/src/download Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -170,15 +170,22 @@ impl NavdataDownloader {
170170 }
171171 // Safe to unwrap since we already checked if it was an error
172172 let json = json_result. unwrap ( ) ;
173- let url = json[ "url" ] . as_str ( ) . unwrap_or_default ( ) ;
173+ let url = json[ "url" ] . as_str ( ) . unwrap_or_default ( ) . to_owned ( ) ;
174174
175175 // Check if json has "folder"
176176 let folder = json[ "folder" ] . as_str ( ) . unwrap_or_default ( ) . to_owned ( ) ;
177177
178+ // Make sure we have both a url and a folder
179+ if url. is_empty ( ) || folder. is_empty ( ) {
180+ let mut status = self . status . borrow_mut ( ) ;
181+ * status = DownloadStatus :: Failed ( "URL or folder is empty" . to_string ( ) ) ;
182+ return ;
183+ }
184+
178185 // Create the request
179186 let captured_self = self . clone ( ) ;
180187 println ! ( "[WASM] Creating request" ) ;
181- match NetworkRequestBuilder :: new ( url)
188+ match NetworkRequestBuilder :: new ( & url)
182189 . unwrap ( )
183190 . with_callback ( move |request, status_code| {
184191 captured_self. request_finished_callback ( request, status_code, folder)
You can’t perform that action at this time.
0 commit comments