diff --git a/public/javascripts/app/views/content_view.js b/public/javascripts/app/views/content_view.js index fc7541ba4..df70f9070 100644 --- a/public/javascripts/app/views/content_view.js +++ b/public/javascripts/app/views/content_view.js @@ -42,8 +42,8 @@ app.views.Content = app.views.StreamObject.extend({ } function urlify(text) { - 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) { + 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, bang) { 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 569b8ca8b..0f7a14678 100644 --- a/spec/javascripts/app/views/post_view_spec.js +++ b/spec/javascripts/app/views/post_view_spec.js @@ -142,6 +142,14 @@ describe("app.views.Post", function(){ }) }) + it("works with urls that use #! syntax (i'm looking at you, twitter)')", function(){ + link = "http://twitter.com/#!/hashbangs?gross=true" + this.statusMessage.set({text : link}) + var view = new app.views.Post({model : this.statusMessage}).render(); + + 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"