Skip to content
Browse files

fix issue with url encoding anchors

  • Loading branch information...
1 parent 531d771 commit 28b8a6a7a3327723868ac4269cf497a3c3538956 @chriskite committed
Showing with 9 additions and 1 deletion.
  1. +1 −1 lib/anemone/page.rb
  2. +8 −0 spec/page_spec.rb
View
2 lib/anemone/page.rb
@@ -62,7 +62,7 @@ def links
doc.search("//a[@href]").each do |a|
u = a['href']
next if u.nil? or u.empty?
- abs = to_absolute(URI(URI.escape(u))) rescue next
+ abs = to_absolute(u) rescue next
@links << abs if in_domain?(abs)
end
@links.uniq!
View
8 spec/page_spec.rb
@@ -126,6 +126,14 @@ module Anemone
end
end
+ describe "#links" do
+ it "should not convert anchors to %23" do
+ page = @http.fetch_page(FakePage.new('', :body => '<a href="#top">Top</a>').url)
+ page.links.should have(1).link
+ page.links.first.to_s.should == SPEC_DOMAIN
+ end
+ end
+
it "should detect, store and expose the base url for the page head" do
base = "#{SPEC_DOMAIN}path/to/base_url/"
page = @http.fetch_page(FakePage.new('body_test', {:base => base}).url)

0 comments on commit 28b8a6a

Please sign in to comment.
Something went wrong with that request. Please try again.