Skip to content

Commit

Permalink
Fix link filter for urls like:
Browse files Browse the repository at this point in the history
  • Loading branch information
crossblaim committed Jul 10, 2009
1 parent fd3cac2 commit 39ae892
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/auto_html/filters/link.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def auto_link_re
(?:\.[-\w]+)* # remaining subdomains or domain
(?::\d+)? # port
(?:/(?:[~\w\+@%=\(\)-]|(?:[,.;:'][^\s$]))*)* # path
(?:\?[\w\+@%&=.;:-]+)? # query string
(?:\?|\#[\w\+@%&=.;:-]+)? # query string
(?:\#[\w\-]*)? # trailing anchor
)
([[:punct:]]|<|$|) # trailing text
Expand Down
7 changes: 6 additions & 1 deletion test/unit/filters/link_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ def test_transform
result = auto_html("http://vukajlija.com") { link }
assert_equal '<a href="http://vukajlija.com">http://vukajlija.com</a>', result
end


def test_transform_complex_url
result = auto_html("http://www.google.com/#q=nikola+tesla&ct=tesla09&oi=ddle&fp=Xmf0jJ9P_V0") { link }
assert_equal '<a href="http://www.google.com/#q=nikola+tesla&ct=tesla09&oi=ddle&fp=Xmf0jJ9P_V0">http://www.google.com/#q=nikola+tesla&ct=tesla09&oi=ddle&fp=Xmf0jJ9P_V0</a>', result
end

def test_transform_with_options
result = auto_html("http://rors.org") { link :rel => "nofollow", :target => "_blank" }
assert_equal '<a href="http://rors.org" rel="nofollow" target="_blank">http://rors.org</a>', result
Expand Down

0 comments on commit 39ae892

Please sign in to comment.