diff --git a/public/javascripts/app/views/content_view.js b/public/javascripts/app/views/content_view.js index 000cfbb09..fc7541ba4 100644 --- a/public/javascripts/app/views/content_view.js +++ b/public/javascripts/app/views/content_view.js @@ -42,8 +42,9 @@ app.views.Content = app.views.StreamObject.extend({ } function urlify(text) { - var urlRegex = /[-a-zA-Z0-9@:%_\+.~#?&//=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?/gi - return text.replace(urlRegex, function(url) { + var urlRegex = /(=\s?'|=\s?")?[-a-zA-Z0-9@:%_\+.~#?&//=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?/gi + return text.replace(urlRegex, function(url, preceeder) { + if(preceeder) return url var protocol = (url.search(/:\/\//) == -1 ? "http://" : "") return "" + url + "" }) diff --git a/spec/javascripts/app/views/post_view_spec.js b/spec/javascripts/app/views/post_view_spec.js index 26893d0d0..569b8ca8b 100644 --- a/spec/javascripts/app/views/post_view_spec.js +++ b/spec/javascripts/app/views/post_view_spec.js @@ -141,6 +141,14 @@ describe("app.views.Post", function(){ expect(view.$("a[href='" + link + "']").text()).toContain(link) }) }) + + it("doesn't create link tags for links that are already in or tags", function(){ + link = "http://google.com" + + this.statusMessage.set({text : "![cats](http://google.com/cats)"}) + var view = new app.views.Content({model : this.statusMessage}) + expect(view.presenter().text).toNotContain('') + }) }) context("user not signed in", function(){