normalizes rels urls in issue https://github.com/G5/microformats2/issues/16
This commit is contained in:
parent
56383a0a91
commit
e630923e1d
3 changed files with 29 additions and 3 deletions
|
@ -110,11 +110,15 @@ module Microformats2
|
||||||
end
|
end
|
||||||
|
|
||||||
def absolutize(href)
|
def absolutize(href)
|
||||||
if URI.parse(href).absolute? || @base.nil?
|
uri = URI.parse(href)
|
||||||
href
|
|
||||||
|
if uri.scheme || @base.nil?
|
||||||
|
uri = uri.normalize
|
||||||
else
|
else
|
||||||
URI.join(@base, href).to_s
|
uri = URI.join(@base, href)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
uri.to_s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -191,6 +191,17 @@ describe Microformats2::Collection do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "rels-with-unnormalized-urls.html" do
|
||||||
|
before do
|
||||||
|
html = "spec/support/lib/microformats2/rels-with-unnormalized-urls.html"
|
||||||
|
@collection = Microformats2.parse(html)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should normalize the url" do
|
||||||
|
@collection.to_hash[:rels]["me"].should eq([ "http://jessicard.com/" ])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "rels-that-drop-the-base.html" do
|
describe "rels-that-drop-the-base.html" do
|
||||||
before do
|
before do
|
||||||
html = "spec/support/lib/microformats2/rels-that-drop-the-base.html"
|
html = "spec/support/lib/microformats2/rels-that-drop-the-base.html"
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Rels Test</title>
|
||||||
|
<base href="http://example.org/">
|
||||||
|
<link rel="updates alternate" href="http://tantek.com/updates.atom" type="application/atom+xml" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<li><a rel="me" href="http://jessicard.com">Jessica Dillon</a></li>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Add table
Add a link
Reference in a new issue