Skip to content

Commit 2aa9288

Browse files
committed
1 parent 836bd16 commit 2aa9288

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

app/logical/d_text.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def self.parse_post_links(str)
103103
def self.parse_id_links(str)
104104
str = str.gsub(/\bpost #(\d+)/i, %{<a href="/posts/\\1">post #\\1</a>})
105105
str = str.gsub(/\bforum #(\d+)/i, %{<a href="/forum_posts/\\1">forum #\\1</a>})
106-
str = str.gsub(/\btopic #(\d+)/i, %{<a href="/forum_topics/\\1">topic #\\1</a>})
106+
str = str.gsub(/\btopic #(\d+)(?:\/p(\d+))?/i, %{<a href="/forum_topics/\\1?page=\\2">topic #\\1</a>})
107107
str = str.gsub(/\bcomment #(\d+)/i, %{<a href="/comments/\\1">comment #\\1</a>})
108108
str = str.gsub(/\bpool #(\d+)/i, %{<a href="/pools/\\1">pool #\\1</a>})
109109
str = str.gsub(/\buser #(\d+)/i, %{<a href="/users/\\1">user #\\1</a>})

test/unit/dtext_test.rb

+4
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,8 @@ def test_table
168168
def test_table_with_newlines
169169
assert_equal("<table class=\"striped\"><thead>\n<tr>\n<th>header</th></tr></thead><tbody><tr><td><a href=\"/posts/100\">post #100</a></td></tr></tbody></table>", p("[table]\n[thead]\n[tr]\n[th]header[/th][/tr][/thead][tbody][tr][td]post #100[/td][/tr][/tbody][/table]"))
170170
end
171+
172+
def test_forum_links
173+
assert_equal('<p><a href="/forum_topics/1234?page=4">topic #1234</a></p>', p("topic #1234/p4"))
174+
end
171175
end

0 commit comments

Comments
 (0)