obsidian-advanced-uri
obsidian-advanced-uri copied to clipboard
Data in ObsidianProtocolData already decoded?
I noticed a bookmarklet I developed that used advanced-ur broke today. Debugging in obsidian showed that the the following line was throwing a URIError: URL malformed
https://github.com/Vinzent03/obsidian-advanced-uri/blob/5b9f810d9d7715d200a5b25a50d20983eb5fc384/src/main.ts#L85
It looks like the ObsidianProtocalData is already decoded.
This URL obsidian://advanced-uri?vault=Personal&daily=true&heading=Daily%20Log&data=-%20%5B2021-2022%20Federal%20Income%20Tax%20Brackets%20%26%20Tax%20Rates%20-%20NerdWallet%5D(https%3A%2F%2Fwww.nerdwallet.com%2Farticle%2Ftaxes%2Ffederal-income-tax-brackets)%20%23bookmark-clipper%0ATax%20rate%0A%0ATaxable%20income%20bracket%0A%0ATaxes%20owed%0A%0A10%25%0A%0A---%0A%0A&mode=prepend
can be decoded just fine.
When it gets to the data parameter in Obsidian, the value is already decoded and the %
causes the error.

It looks like this passed in decoded data.
https://github.com/obsidianmd/obsidian-api/blob/1b4f6e2e5753c8ac2d538bc5d55c38f228450cb2/obsidian.d.ts#L2666
I can send a PR if you like.
I'm double encoding it, because I experienced cases, where it was necessary. For example when launching it from the terminal on linux with xdg-open
. You didn't use the build in commands to build the uri, right? I know it's a bit strange, but I made the best experience so far with double encoding.
I am building the URL from a web bookmarklet.
https://github.com/jgchristopher/obsidian-clipper-bookmarklet/blob/2631c1483f78b675ae382b5358c033caf784a2cd/src/index.ts#L60
I will probably keep the double encoding. I see you solved the issue by double encoding it on your end as well.