alexjv89 / markdown-it-obsidian

Convert obsidian wiki links to markdown links
MIT License
48 stars 5 forks source link

Handle Windows path dividers #2

Open notleigh opened 1 month ago

notleigh commented 1 month ago

The current implementation assumes unix/mac / path separators, which neatly maps to URLs. However when running on Windows as the path separators are \ each the items will not be added to the shortlisted hrefs due to index.js:122:

          if(href[i-1]=='/')
            shortlists.push(href);

Which results in no pages being found when resolving Obsidian style [[internal-links]].

This change swaps out path.sep characters with / when converting the file path to a href to allow the shortlisted href check to pass as expected. It also uses path.join & path.sep to attempt to keep Windows behaviour consistent with other OS path handling.