From 2ce59d25853d68ef80c545e8b0a36f24af62f5c3 Mon Sep 17 00:00:00 2001
From: Robin Ward <robin.ward@gmail.com>
Date: Sat, 24 Aug 2013 15:08:36 -0400
Subject: [PATCH] FIX: If a topic/post cannot be oneboxed, don't swallow the
 href.

---
 lib/oneboxer/discourse_local_onebox.rb | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/oneboxer/discourse_local_onebox.rb b/lib/oneboxer/discourse_local_onebox.rb
index 8329737dc..5cddb4fb0 100644
--- a/lib/oneboxer/discourse_local_onebox.rb
+++ b/lib/oneboxer/discourse_local_onebox.rb
@@ -28,12 +28,13 @@ module Oneboxer
 
         @template = 'user'
       when 'topics'
+
+        linked = "<a href='#{@url}'>#{@url}</a>"
         if route[:post_number].present? && route[:post_number].to_i > 1
           # Post Link
           post = Post.where(topic_id: route[:topic_id], post_number: route[:post_number].to_i).first
-          return nil unless post
-
-          return @url unless Guardian.new.can_see?(post)
+          return linked unless post
+          return linked unless Guardian.new.can_see?(post)
 
           topic = post.topic
           slug = Slug.for(topic.title)
@@ -50,9 +51,8 @@ module Oneboxer
         else
           # Topic Link
           topic = Topic.where(id: route[:topic_id].to_i).includes(:user).first
-          return nil unless topic
-
-          return @url unless Guardian.new.can_see?(topic)
+          return linked unless topic
+          return linked unless Guardian.new.can_see?(topic)
 
           post = topic.posts.first