Commit b34803bd67d48e9595b129b31424da6ed513740b
- Diff rendering mode:
- inline
- side by side
coefficient.rb
(2 / 2)
|   | |||
| 4 | 4 | require 'json' | |
| 5 | 5 | require 'rack/utils' | |
| 6 | 6 | ||
| 7 | #RestClient.proxy = "http://localhost:8118" | ||
| 7 | RestClient.proxy = "http://localhost:8118" | ||
| 8 | 8 | set :host, 'localhost' | |
| 9 | 9 | disable :logging | |
| 10 | 10 | ||
| … | … | ||
| 65 | 65 | # XXX: + also breaks it | |
| 66 | 66 | ||
| 67 | 67 | # 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=" | ||
| 69 | 69 | new.gsub!(/@([0-9a-zA-Z_]+)/, '@<a href="http://twitter.com/\1">\1</a>') | |
| 70 | 70 | return new | |
| 71 | 71 | end |
tests/unit.rb
(24 / 0)
|   | |||
| 63 | 63 | assert_equal "some stuff <a href=\"http://google.com/whatever\">http://google.com/whatever</a>:", | |
| 64 | 64 | linkify("some stuff http://google.com/whatever:") | |
| 65 | 65 | 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 "" do | ||
| 80 | assert_equal %Q("Fine. You got me. I totally started it. <a href="http://tinyurl.com/m4xkrt">http://tinyurl.com/m4xkrt</a>" Oh), | ||
| 81 | linkify(""Fine. You got me. I totally started it. http://tinyurl.com/m4xkrt" Oh") | ||
| 82 | end | ||
| 83 | |||
| 66 | 84 | end | |
| 67 | 85 | ||
| 86 | # http://abclocal.go.com/wabc/story?section=news/local&id=6871701 | ||
| 68 | 87 | context "when making a user link" do | |
| 69 | 88 | setup do | |
| 70 | 89 | @identica = { | |
| … | … | ||
| 184 | 184 | should "linkify hashtags from identica" do | |
| 185 | 185 | assert_equal "I like #<a href=\"http://identi.ca/tag/pie\">pie</a>", | |
| 186 | 186 | parse_text("identica", "I like #pie") | |
| 187 | end | ||
| 188 | |||
| 189 | should "correctly handle " at the end of the url" do | ||
| 190 | assert_equal ""Fine. You got me. I totally started it. <a href=\"http://tinyurl.com/m4xkrt\">http://tinyurl.com/m4xkrt</a>"", | ||
| 191 | parse_text("twitter", "\"Fine. You got me. I totally started it. http://tinyurl.com/m4xkrt\"") | ||
| 187 | 192 | end | |
| 188 | 193 | end | |
| 189 | 194 |

