phd20 / obsidian-discord-share

This plugin allows you to share your Obsidian Vault content to Discord using discord.js.
MIT License
29 stars 3 forks source link

Is it possible to use Obsidian URI in ods-url? #15

Closed ooker777 closed 1 year ago

ooker777 commented 1 year ago

I try to use the Obsidian URI:

obsidian://open?vault=Land%20of%20Spheres&file=4%20S%E1%BA%A3n%20ph%E1%BA%A9m%2C%20k%E1%BA%BFt%20qu%E1%BA%A3%20mong%20mu%E1%BB%91n%20(c%C3%A1c%20v%C3%B9ng%20%C4%91%E1%BA%A5t)%2F4A%20%C4%90%C3%A1m%20m%C3%A2y%20chim%20s%C3%A1o%20l%C3%B4ng%20v%C3%A0ng%2F4A1%20K%E1%BA%BFt%20qu%E1%BA%A3%20mong%20mu%E1%BB%91n%2F5%20ng%C6%B0%E1%BB%9Di%20th%C6%B0%E1%BB%9Dng%20xuy%C3%AAn%20%C4%91%C3%B3ng%20g%C3%B3p%20v%C3%A0o%20vault

But it doesn't work. Is there any reason for this?

phd20 commented 1 year ago

I have a feeling that this is a limitation within Discord's API. I found the following digging through their code:

Only three types of URL schemes are currently supported: https://, http:// and discord://

I'm going to keep thinking on this though and I'll see if there are any ways we can work around it.

ooker777 commented 1 year ago

I think the simplest solution is to change the URI from obsidian:\\ to https:\\somedomain.com\, then redirect it from there back to obsidian:\\. However I don't know how to get the URI of the current note from the console

phd20 commented 1 year ago

I'll keep thinking about this. I'm not sure this plugin is the right place to handle externally configured redirects. In the meantime, I've tested a workaround:

Workaround

You can set up a Replace String Rule in an app like Requestly. For example, I set up the following:

Since this is using a proxy, it doesn't care that https://obsidian-discord-share.com/ isn't a real URL and correctly redirects back to the Obsidian vault.

Downside

It is proxying your traffic. Not ideal and something to be aware of.

phd20 commented 1 year ago

After further research, I think it's best to leave this as-is. To get around Discord's restrictions, folks can follow the workaround above or set up their own redirects.