Hello, I've been using play.d2lang.com to make diagrams and store them in a wiki page over the last few weeks. Pretty nice, thanks! I noticed this week that the URLs I had stored were broken. When I clicked them my elaborate diagrams started to only show a dreaded:
x -> y
I decided to figure out why and I found that the URL encoded changed in the d2 repository, in a commit from Nov 7: terrastruct/d2@5eead31
This did not take effect on the d2 playground site until d2 was upgraded for the deployed wasm, on Dec 6: ae1e9c3
When the bundled, WASM version of d2 was deployed this created a cutoff date. Any URLs generated before the cutoff would no longer properly decode their embedded d2 "scripts". Only URLs for documents created after the cutoff date would decode properly.
The following is a Go program I used to convert old URLs to the new URLs. I read the above commit and decoded using the old deflate dictionary, then encoding with the same parameters as the new urlenc.Encode
. I just wanted to share that with anyone who needs it.
https://gist.github.com/jrcd-HR/92ef3407c9f5061787b7c7a095a031ea
I'm not sure how to fix it, other than first trying the new url.Decode
method, and then trying the backup method if that fails. Of course, the problem is that the backup method is no longer implemented in the d2 wasm.