nfrasser / linkifyjs

JavaScript plugin for finding links in plain-text and converting them to HTML <a> tags.
https://linkify.js.org
MIT License
1.84k stars 184 forks source link

ws and wss suport for test method #484

Closed jhercog closed 4 months ago

jhercog commented 4 months ago

Right now linkify.test('wss://example.com/event') returns false. Also, there is no 'type' argument for testing against WebSocket urls.

Please validate urls with wss/ws scheme as true or include the type argument which would make it so E.g. linkify.test('wss://example.com/event', 'websocket') or similar.

nfrasser commented 4 months ago

@jhercog thanks for reporting, this should work if you register wss as a custom protocol before calling test:

linkify.registerCustomProtocol('wss');
linkify.test('wss://example.com/event') // true

Note that you only need to call this once for the lifetime of your script, e.g., right after importing Linkify.

jhercog commented 4 months ago

@nfrasser Thank you for the info, it is just what i need.