Commit b34803bd67d48e9595b129b31424da6ed513740b

More urls that were not parsed correctly. Tests and corresponding fixes.
  
44require 'json'
55require 'rack/utils'
66
7#RestClient.proxy = "http://localhost:8118"
7RestClient.proxy = "http://localhost:8118"
88set :host, 'localhost'
99disable :logging
1010
6565 # XXX: + also breaks it
6666
6767 # maybe laconica-0.7.3/lib/util.php:common_replace_urls_callback() ?
68 new.gsub!(/(https?:\/\/([a-zA-Z0-9_%\-+?#\/]|\.(?!\z|\s))+)/, '<a href="
68 new.gsub!(/(https?:\/\/([a-zA-Z0-9_%\-+?#\/,=]|&(?!quot;)|\.(?!\z|\s))+)/, '<a href="
6969 new.gsub!(/@([0-9a-zA-Z_]+)/, '@<a href="http://twitter.com/\1">\1</a>')
7070 return new
7171end
  
6363 assert_equal "some stuff <a href=\"http://google.com/whatever\">http://google.com/whatever</a>:",
6464 linkify("some stuff http://google.com/whatever:")
6565 end
66
67 should "correctly parse urls containing =" do
68 assert_equal "stuff <a href=\"http://nyellee.com/wordpress/?p=284\">http://nyellee.com/wordpress/?p=284</a> stuff", linkify("stuff http://nyellee.com/wordpress/?p=284 stuff")
69 end
70
71 should "correctly parse urls containing ," do
72 assert_equal "stuff <a href=\"http://www.foxnews.com/story/0,2933,526597,00.html\">http://www.foxnews.com/story/0,2933,526597,00.html</a> stuff", linkify("stuff http://www.foxnews.com/story/0,2933,526597,00.html stuff")
73 end
74
75 should "correctly parse urls containing &" do
76 assert_equal "stuff <a href=\"http://abclocal.go.com/wabc/story?section=news/local&id=6871701\">http://abclocal.go.com/wabc/story?section=news/local&id=6871701</a> stuff", linkify("stuff http://abclocal.go.com/wabc/story?section=news/local&id=6871701 stuff")
77 end
78
79 should "correctly parse urls ending in &quot;" do
80 assert_equal %Q(&quot;Fine. You got me. I totally started it. <a href="http://tinyurl.com/m4xkrt">http://tinyurl.com/m4xkrt</a>&quot; Oh),
81 linkify("&quot;Fine. You got me. I totally started it. http://tinyurl.com/m4xkrt&quot; Oh")
82 end
83
6684 end
6785
86 # http://abclocal.go.com/wabc/story?section=news/local&id=6871701
6887 context "when making a user link" do
6988 setup do
7089 @identica = {
184184 should "linkify hashtags from identica" do
185185 assert_equal "I like #<a href=\"http://identi.ca/tag/pie\">pie</a>",
186186 parse_text("identica", "I like #pie")
187 end
188
189 should "correctly handle &quot; at the end of the url" do
190 assert_equal "&quot;Fine. You got me. I totally started it. <a href=\"http://tinyurl.com/m4xkrt\">http://tinyurl.com/m4xkrt</a>&quot;",
191 parse_text("twitter", "\"Fine. You got me. I totally started it. http://tinyurl.com/m4xkrt\"")
187192 end
188193 end
189194