truffle-hog 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module TruffleHog
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
 
4
4
  def self.parse_feed_urls(html, favor = :all)
5
5
  rss_links = scan_for_tag(html, "rss")
@@ -23,7 +23,12 @@ module TruffleHog
23
23
  tags = html.scan(/(<#{tag}.*?>)/).flatten
24
24
  feed_tags = collect(tags, type)
25
25
  feed_tags.map do |tag|
26
- url = tag.match(/.*href=['"](.*?)['"].*/)[1]
26
+ matches = tag.match(/.*href=['"](.*?)['"].*/)
27
+ if matches.nil?
28
+ url = ""
29
+ else
30
+ url = matches[1]
31
+ end
27
32
  url =~ /^http.*/ ? url : nil
28
33
  end.compact
29
34
  end
@@ -39,11 +39,15 @@ describe "parsing html" do
39
39
  it "returns atom feeds if rss is favored, but none are found"
40
40
  it "returns rss feeds if atom is favored, but none are found"
41
41
 
42
- describe "odd regressions" do
42
+ describe "regressions" do
43
43
  it "doesn't go into an infinite loop on this input" do
44
44
  input = File.read("#{File.dirname(__FILE__)}/infinite.html")
45
45
  feed_urls = TruffleHog.parse_feed_urls(input)
46
46
  feed_urls.should == ["http://feeds.feedburner.com/cryptload"]
47
47
  end
48
+
49
+ it "doesn't break when an anchor without an href is passed" do
50
+ TruffleHog.parse_feed_urls("<a type='application/rss+xml'>").should == []
51
+ end
48
52
  end
49
53
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: truffle-hog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Dix