Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

registerCustomProtocol doesn't linkify without double slashes #372

Closed
aaronraimist opened this issue Jan 14, 2022 · 5 comments · Fixed by #354
Closed

registerCustomProtocol doesn't linkify without double slashes #372

aaronraimist opened this issue Jan 14, 2022 · 5 comments · Fixed by #354

Comments

@aaronraimist
Copy link

The description for linkify.registerCustomProtocol says "Linkify will consider any string that begins with the given protocol followed by a : as a URL link" but that doesn't seem to be true. Linkifyjs seems to be looking for :// after the protocol for it to be considered a link.

URI schemes without an authority component such as geo:, matrix:, and xmpp: don't get linkified.

Here is an example: https://codepen.io/aaronraimist/pen/bGoOXrq. Only mailto gets linkified.

import * as linkify from "https://cdn.skypack.dev/linkifyjs";
import linkifyStr from "https://cdn.skypack.dev/linkify-string";

linkify.registerCustomProtocol("geo");
linkify.registerCustomProtocol("matrix");
linkify.registerCustomProtocol("xmpp");

createLink("mailto:[email protected]");
createLink("geo:37.786971,-122.399677");
createLink("matrix:r/someroom:example.org");
createLink("xmpp:[email protected]?message");

function createLink(string) {
  console.log(linkifyStr(string));
  console.log(linkify.test(string));
}
@nfrasser nfrasser self-assigned this Jan 14, 2022
@nfrasser nfrasser added this to the 4.0 milestone Jan 14, 2022
@nfrasser
Copy link
Owner

Hi @aaronraimist, thanks for reporting. This is a known issue and will be fixed in v4 (#354)

@toger5
Copy link

toger5 commented Jan 19, 2022

when will this be ready?
I am currently adding a custom parser for matrix:u/... links. This causes all kinds of issues. Maybe I should open specific issues in what I am running into. This would be really really helpful!

@nfrasser
Copy link
Owner

@toger5 a beta is now available that you can try out:

npm install linkifyjs@beta

(Requires @beta versions of related Linkify plugins and interfaces)

@nfrasser
Copy link
Owner

No timeline yet on a stable release, there's still a few more features that need development

@nfrasser
Copy link
Owner

nfrasser commented Sep 19, 2022

Fixed in latest v4 release. Have to add a second true argument to the registerCustomPrococol function call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants