11import  LinkConverterPlugin  from  'main' ; 
2- import  {  App ,  TFile ,  normalizePath ,   Notice  }  from  'obsidian' ; 
2+ import  {  App ,  TFile ,  Notice  }  from  'obsidian' ; 
33
44/* -------------------- LINK DETECTOR -------------------- */ 
55
@@ -109,11 +109,10 @@ const getAllLinkMatchesInFile = async (mdFile: TFile, plugin: LinkConverterPlugi
109109
110110// --> Converts single file to provided final format and save back in the file 
111111export  const  convertLinksAndSaveInSingleFile  =  async  ( mdFile : TFile ,  plugin : LinkConverterPlugin ,  finalFormat : 'markdown'  |  'wiki' )  =>  { 
112-     let  normalizedPath  =  normalizePath ( mdFile . path ) ; 
113112    let  fileText  =  await  plugin . app . vault . read ( mdFile ) ; 
114113    let  newFileText  = 
115114        finalFormat  ===  'markdown'  ? await  convertWikiLinksToMarkdown ( fileText ,  mdFile ,  plugin )  : await  convertMarkdownLinksToWikiLinks ( fileText ,  mdFile ,  plugin ) ; 
116-     await  plugin . app . vault . adapter . write ( normalizedPath ,  newFileText ) ; 
115+     await  plugin . app . vault . modify ( mdFile ,  newFileText ) ; 
117116} ; 
118117
119118// --> Command Function: Converts All Links and Saves in Current Active File 
@@ -199,8 +198,7 @@ const convertMarkdownLinksToWikiLinks = async (md: string, sourceFile: TFile, pl
199198/* -------------------- LINKS TO RELATIVE/ABSOLUTE/SHORTEST -------------------- */ 
200199
201200export  const  convertLinksInFileToPreferredFormat  =  async  ( mdFile : TFile ,  plugin : LinkConverterPlugin ,  finalFormat : FinalFormat )  =>  { 
202-     let  normalizedPath  =  normalizePath ( mdFile . path ) ; 
203-     let  fileText  =  await  plugin . app . vault . adapter . read ( normalizedPath ) ; 
201+     let  fileText  =  await  plugin . app . vault . read ( mdFile ) ; 
204202    let  linkMatches : LinkMatch [ ]  =  await  getAllLinkMatchesInFile ( mdFile ,  plugin ) ; 
205203    for  ( let  linkMatch  of  linkMatches )  { 
206204        let  fileLink  =  decodeURI ( linkMatch . linkText ) ; 
@@ -210,7 +208,7 @@ export const convertLinksInFileToPreferredFormat = async (mdFile: TFile, plugin:
210208            fileText  =  fileText . replace ( linkMatch . match ,  createLink ( linkMatch . type ,  fileLink ,  linkMatch . altOrBlockRef ,  mdFile ,  plugin ) ) ; 
211209        } 
212210    } 
213-     await  plugin . app . vault . adapter . write ( normalizedPath ,  fileText ) ; 
211+     await  plugin . app . vault . modify ( mdFile ,  fileText ) ; 
214212} ; 
215213
216214const  getFileLinkInFormat  =  ( file : TFile ,  sourceFile : TFile ,  plugin : LinkConverterPlugin ,  finalFormat : FinalFormat ) : string  =>  { 
0 commit comments