Incorrect file:// URLs generated by drop on Windows

Steps to reproduce

Drag a file from Windows Explorer to an Obsidian editor pane, hold Ctrl and drop.

Expected result

A standard Windows file:///C|/path/to/file-style URL should be inserted (note vertical bar and forward slashes)

Actual result

The actual link is file:///C:%5Cpath%5Cto%5Cfile (colon and escaped backslashes), which is not supported by all Windows tools. (For example, attempting to open such URLs in Chrome does not work.)

Environment

  • Operating system: Windows
  • Obsidian version: 0.12.10

Additional information

To create a proper Windows file: URL, the backslashes must be replaced with slashes, and the colon replaced with a vertical bar, before URL-encoding the result. (e.g. in handleDropIntoEditor(), but ideally anywhere else Obsidian converts a Windows path into a file: URL as well.)

1 Like