@@ -81,6 +81,7 @@ impl FileChecker {
8181 ///
8282 /// Returns a `Status` indicating the result of the check.
8383 pub ( crate ) async fn check ( & self , uri : & Uri ) -> Status {
84+ //only populate the wikilink filenames if it is enabled
8485 if self . include_wikilinks {
8586 self . setup_wikilinks ( ) . await ;
8687 }
@@ -145,8 +146,12 @@ impl FileChecker {
145146 ) -> Result < Cow < ' a , Path > , ErrorKind > {
146147 let path = match path. metadata ( ) {
147148 // for non-existing paths, attempt fallback extensions
149+ // if fallback extensions don't help, try wikilinks
148150 Err ( e) if e. kind ( ) == std:: io:: ErrorKind :: NotFound => {
149- self . apply_fallback_extensions ( path, uri) . map ( Cow :: Owned )
151+ match self . apply_fallback_extensions ( path, uri) . map ( Cow :: Owned ) {
152+ Ok ( val) => Ok ( val) ,
153+ Err ( _) => self . apply_wikilink_check ( path, uri) . await . map ( Cow :: Owned ) ,
154+ }
150155 }
151156
152157 // other IO errors are unexpected and should fail the check
@@ -257,7 +262,7 @@ impl FileChecker {
257262 }
258263
259264 /// Checks a resolved file, optionally verifying fragments for HTML files.
260- ///
265+ ///u
261266 /// # Arguments
262267 ///
263268 /// * `path` - The resolved path to check.
@@ -323,7 +328,16 @@ impl FileChecker {
323328 // Tries to resolve a link by looking up the filename in the wikilink index
324329 // The
325330 async fn apply_wikilink_check ( & self , path : & Path , uri : & Uri ) -> Result < PathBuf , ErrorKind > {
326- self . wikilink_checker . check ( path, uri) . await
331+ let mut path_buf = path. to_path_buf ( ) ;
332+ for ext in & self . fallback_extensions {
333+ path_buf. set_extension ( ext) ;
334+ match self . wikilink_checker . check ( & path_buf, uri) . await {
335+ Err ( _) => { }
336+ Ok ( resolved_path) => return Ok ( resolved_path) ,
337+ }
338+ }
339+
340+ Err ( ErrorKind :: InvalidFilePath ( uri. clone ( ) ) )
327341 }
328342}
329343
0 commit comments