gregjacobs/Autolinker.js — pull request #16 by aziraphale (2014-03-11 20:49:03+00:00)
Title: Added options to control which link types are autolinked

My usage didn't want Twitter handles to be auto-linked, and sometimes only wanted email addresses to be linked, so I've added some extra options to control which of the three types should be processed.

This still uses the same regex to match all 3 link types regardless of which are enabled - it merely skips over link types that aren't wanted when processing them into `` tags. This is perhaps not ideal for performance (especially if the `.link()` function is being called repeatedly), but it saves us having multiple regular expressions (which in turn saves the client having to download and compile multiple regex patterns). I'm satisfied with the trade-off, there.

This could arguably do with more tests, too. The included tests show that it essentially works, but there are many avenues where it could *potentially* fail, in theory, so more tests are always beneficial, I guess! I've been a little too pushed for time to write any more tests than absolutely necessary... (Testing/QA is always the first to be cut in a budget/deadline squeeze, eh? :))

**Note:** this pull request doesn't include any of the files in `/dist/` as I figured that they would only be a monumental pain in the arse to merge, but it means that anyone downloading an archive of this project immediately after this PR is merged wouldn't have this functionality available in the compiled files in `/dist/`, so the code will need to be built and committed before it's done. I'm happy to include the `/dist/` files in the PR if you wish - just let me know! :)