Skip to content

Commit

Permalink
fix issue with url encoding anchors
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskite committed May 30, 2012
1 parent 531d771 commit 28b8a6a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/anemone/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
8 changes: 8 additions & 0 deletions spec/page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 28b8a6a

Please sign in to comment.