obsidian-url-into-selection icon indicating copy to clipboard operation
obsidian-url-into-selection copied to clipboard

Strip Surrounding Quotation Marks from Filepaths (and URLs?)

Open CDWimmer opened this issue 6 months ago • 0 comments

Howdy,

Most of the time in Obsidian I'm working with file:/// paths out of the browser, of which paste nicely :) i.e. file:///V:/2022 Trading Calendar.xlsx pasted into a selection makes a nice enough result: [some text](<file:///V:/2022 Trading Calendar.xlsx>)

However, it's sometimes far more convenient to grab a file path from Explorer, which does not care to emit URL formatting.

On Windows, if you hold shift when right-clicking in Explorer, a file and select "Copy as path" you are given a quote-wrapped path in Windows format, with back-slash separators and spaces are spaces. i.e. for the same file as before, "V:\2022 Trading Calendar.xlsx" is the full string copied.

Pasting this over the text "some text" results in: [some text](<"V:\2022 Trading Calendar.xlsx">)

Windows (and presumably other non-browser systems) adds the quote marks to paths with spaces so that in the shell it understands when a path with spaces starts and ends. The < > wrapping achieves this for us in Markdown.

Clicking this causes an error in Obsidian as it tried to URL-encode the leading quotation mark into %22, which is obviously not a valid way to start a URL.

Removing the quotes allows Obsidian to turn it into a proper file:/// URL: [some text](<V:\2022 Trading Calendar.xlsx>): image

It would be very much a welcomed convenience if this could detect and strip of a pair of leading/trailing quotation marks around a URL or a file path such that Obsidian will generate valid URLs from it without modification.

CDWimmer avatar Aug 13 '24 13:08 CDWimmer