markdown-it / linkify-it

Links recognition library with full unicode support
http://markdown-it.github.io/linkify-it/
MIT License
655 stars 63 forks source link

Non Standard Links such as Deep Linking #64

Closed serialbandicoot closed 6 years ago

serialbandicoot commented 6 years ago

I'm using an app, which in turn is using your library and unfortunately :( your library rejects urls, which are used for deep-linking (universal link) in an iOS app.

So my internal linking mechanism is using myapp://xyz/1 - this enables me to deep link into the app.

However this is rejected as being a non-standard url by your library. Would you have a way of passing into the library an option, which validates it as a deep link.

puzrin commented 6 years ago

https://github.com/markdown-it/linkify-it#addkey-value you should extend existing schemas with new ones.

serialbandicoot commented 6 years ago

Many thanks @puzrin

ronenmiller-khealth commented 3 years ago

@serialbandicoot Can you write an example of how you ended up using this capability?

tegozen commented 3 years ago

@serialbandicoot Can you write an example of how you ended up using this capability?

const linkify = require('linkify-it')()
linkify.add('appname://', {
  validate: function (text, pos, self) {
    var tail = text.slice(pos);

    if (!self.re.appname) {
      self.re.appname = new RegExp(
        '^([a-zA-Z0-9_/]){1,15}(?!_)(?=$|' + self.re.src_ZPCc + ')'
      );
    }
    if (self.re.appname.test(tail)) {
      return tail.match(self.re.appname)[0].length;
    }
    return 0;
  },
});
serialbandicoot commented 3 years ago

Hey @tegozen, I don’t have access the code anymore. However the issue I had was due to an inter library dependency. I think, from memory in the end I used patch-package to add in the linkify.add(‘app name:’, true) which allowed the schema. So my code worked. Good luck.