Skip to content

Instantly share code, notes, and snippets.

View sydlawrence's full-sized avatar

Syd Lawrence sydlawrence

View GitHub Profile
@codeincontext
codeincontext / linkify.js
Created December 20, 2011 12:17
Linkify urls in a JS string
// I didn't do this. This guy did: http://stackoverflow.com/a/7123542/288660
if(!String.linkify) {
String.prototype.linkify = function() {
// http://, https://, ftp://
var urlPattern = /\b(?:https?|ftp):\/\/[a-z0-9-+&@#\/%?=~_|!:,.;]*[a-z0-9-+&@#\/%=~_|]/gim;
// www. sans http:// or https://
var pseudoUrlPattern = /(^|[^\/])(www\.[\S]+(\b|$))/gim;