Possibly an odd question, but I'm sure someone has thought of it before :) I'm wondering if it's at all possible to verify a given string as being a theoretically valid Magnet link, using JS.
Not particularly bothered about opening the link etc. (That's done elsewhere), I'm more concerned here about weeding out broken/ truncated links.
The best I can come up with from the top of my head is a simple beginning of string match for the magnet:?xt=urn:
I suppose I could preface this with a length condition (20+ characters seems reasonable?), but does anyone have a 'better' solution?
The JavaScript:
Short:
Wikipedia about Magnet URI scheme