gregjacobs / Autolinker.js

Utility to Automatically Link URLs, Email Addresses, Phone Numbers, Twitter handles, and Hashtags in a given block of text/HTML
MIT License
1.48k stars 239 forks source link

Request: Adding a new hashtag provider #336

Open the-conqueror-97 opened 3 years ago

the-conqueror-97 commented 3 years ago

Hi, i just found this library and i believe it can be improved. So i would like to add one more provider to the project.

So we have already Facebook, Twitter and Instagram. I would like to add "Aktagram".

If it could be added as soon as possible it would be nice.

/**

  • Returns the anchor href that should be generated for the match.
  • @return {String} */ HashtagMatch.prototype.getAnchorHref = function () { var serviceName = this.serviceName, hashtag = this.hashtag; switch (serviceName) { case 'twitter': return 'https://twitter.com/hashtag/' + hashtag; case 'facebook': return 'https://www.facebook.com/hashtag/' + hashtag; case 'instagram': return 'https://instagram.com/explore/tags/' + hashtag; case 'aktagram': return 'https://aktagram.com/hashtag/' + hashtag; default: // Shouldn't happen because Autolinker's constructor should block any invalid values, but just in case. throw new Error('Unknown service name to point hashtag to: ' + serviceName); } };
olafleur commented 3 years ago

PRs are welcome! :)