Open danielwerg opened 2 months ago
Hi, thanks for the feedback again. Adding encoding should be straightforward and I can add it soon. Also just to confirm, Is your note called "obsidian://open?vault=obsidian&file=note%20with%20space" or is that a mistake on the description?
obsidian-cli open "obsidian://open?vault=obsidian&file=note%20with%20space"
Note called note with space
, when you Copy Obsidian URL
inside obsidian obsidian://open?vault=VAULT&file=note%20with%20space
is copied, after note title is run through encodeURI
.
But you would call the obsidian-cli open "note with space"
or with encoding it will be obsidian cli open "note%20with%20space"
. The former functionality works as expected, and the latter I can add to the tool, although I didn't think there would be a need for it originally.
What I am trying to say is in your example you used obsidian-cli open "obsidian://open?vault=obsidian&file=note%20with%20space"
which is using the entire url in the open command which is not correct usage of the tool.
Oh, I didn't even tested without encoding. I just assumed it would support Obsidian URIs. Added couple more workaround that can parse URI and feed it to obsidian-cli
.
It uses Obsidian URIs in the background, but it doesn't use them as arguments. If you want to use the URI, you can use it directly without using the CLI. e.g. on Mac it would be open "obsidian://open?vault=obsidian&file=note%20with%20space"
Describe the bug
open
doesn't decodes URL-encodingTo Reproduce
Steps to reproduce the behaviour:
obsidian-cli open "obsidian://open?vault=obsidian&file=note%20with%20space"
Expected behaviour
Decode URL and open note
Workarounds
obsidian-cli open "$(encoded_string="obsidian://open?vault=obsidian&file=note%20with%20space"; printf "%b\n" "${encoded_string//\%/\\x}")"
xdg-open "obsidian://open?vault=obsidian&file=note%20with%20space"
obsidian-cli open "$(node -e "console.log(new URL(process.argv[1]).searchParams.get('file'))" "obsidian://open?vault=obsidian&file=note%20with%20space")"
obsidian-cli open "$(trurl "obsidian://open?vault=obsidian&file=note%20with%20space" -g '{query:file}' )"
obsidian-cli open "$(perl -mURI -E 'say URI->new(@ARGV[0])->query_param(file)' -- "obsidian://open?vault=obsidian&file=note%20with%20space")"