Permalink
Browse files

fix #29 - youtube filter swallows text that comes after a link

  • Loading branch information...
1 parent 56a29d3 commit 990127a9f38e41fdafa88f023d101e718e63ebd3 @dejan dejan committed Feb 18, 2012
Showing with 11 additions and 1 deletion.
  1. +5 −0 CHANGELOG.md
  2. +1 −1 lib/auto_html/filters/youtube.rb
  3. +5 −0 test/unit/filters/youtube_test.rb
View
@@ -1,3 +1,8 @@
+## 1.5.1, released 2012-02-18
+* Rails 2.3.1 support
+* Gist filter
+* GoogleMap filter
+
## 1.5.0, released 2011-12-07
* use redcarpet ~> 2.0.0; :renderer option
* use rinku ~> 1.5.0
@@ -1,5 +1,5 @@
AutoHtml.add_filter(:youtube).with(:width => 420, :height => 315, :frameborder => 0, :wmode => nil) do |text, options|
- regex = /(https?):\/\/(www.)?(youtube\.com\/watch\?v=|youtu\.be\/)([A-Za-z0-9_-]*)(\&\S+)?.*/
+ regex = /(https?):\/\/(www.)?(youtube\.com\/watch\?v=|youtu\.be\/)([A-Za-z0-9_-]*)(\&\S+)?(\S)*/
text.gsub(regex) do
protocol = $1
youtube_id = $4
@@ -16,6 +16,11 @@ def test_transform3
result = auto_html('http://www.youtube.com/watch?v=BwNrmYRiX_o&feature=related') { youtube }
assert_equal '<iframe width="420" height="315" src="http://www.youtube.com/embed/BwNrmYRiX_o" frameborder="0" allowfullscreen></iframe>', result
end
+
+ def test_transform3
+ result = auto_html('foo http://www.youtube.com/watch?v=fT1ahr81HLw bar') { youtube }
+ assert_equal 'foo <iframe width="420" height="315" src="http://www.youtube.com/embed/fT1ahr81HLw" frameborder="0" allowfullscreen></iframe> bar', result
+ end
def test_transform_url_without_www
result = auto_html('http://youtube.com/watch?v=BwNrmYRiX_o') { youtube }

0 comments on commit 990127a

Please sign in to comment.