matrix-org / matrix.to

A simple stateless privacy-protecting URL redirecting service for Matrix
http://matrix.to
Apache License 2.0
889 stars 189 forks source link

Add basic support for parsing matrix-URIs (MSC2312) #234

Open Unkn0wnCat opened 2 years ago

Unkn0wnCat commented 2 years ago

Hello all,

This pull request implements basic support for processing matrix-URIs as defined in matrix-org/matrix-doc#2312.

Included in this pull request:

Note that the "matrix:"-prefix is optional. Links like https://deploy-preview-234--matrix-to.netlify.app/#/u/kevin:1in1.net also work!

See also: #205, This PR would work great in conjunction with #223

Hope this helps, let me know if you'd like something changed or if there is something I've overlooked!

-- Kevin

Unkn0wnCat commented 2 years ago

Update: I've changed the links in my description to include the preview link provided by Netlify CI.

You can directly test my fork at https://deploy-preview-234--matrix-to.netlify.app/

Unkn0wnCat commented 2 years ago

Example code for registering matrix.to as a matrix:-protocol-handler with this PR:

navigator.registerProtocolHandler("matrix",
                                  "https://deploy-preview-234--matrix-to.netlify.app/#/%s",
                                  "Matrix");

You can try it out by copying it into your browser console (Tested on Firefox 92.0.1)

Unkn0wnCat commented 2 years ago

After talking to @DanilaFe, I'll now be working on implementing https://github.com/matrix-org/matrix-uri-parser-js into Matrix.to instead of doing something completely new.