Skip to content

Commit

Permalink
handle hostless schemes
Browse files Browse the repository at this point in the history
  • Loading branch information
singpolyma committed May 19, 2011
1 parent 6977ca5 commit f1a6cf7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/postrank-uri.rb
Expand Up @@ -200,7 +200,7 @@ def parse(uri, opts = {})

uri = Addressable::URI.parse(uri)

unless uri.host
if !uri.host && uri.scheme !~ /^javascript|mailto|xmpp$/
if uri.scheme
# With no host and scheme yes, the parser exploded
return parse("http://#{uri}", opts)
Expand Down
12 changes: 12 additions & 0 deletions spec/postrank-uri_spec.rb
Expand Up @@ -320,5 +320,17 @@ def e(text)
it 'should not fail on large host-part look-alikes' do
PostRank::URI.parse('a'*64+'.ca').host.should == nil
end

it 'should not pancake javascript scheme URIs' do
PostRank::URI.parse('javascript:void(0);').scheme.should == 'javascript'
end

it 'should not pancake mailto scheme URIs' do
PostRank::URI.parse('mailto:void(0);').scheme.should == 'mailto'
end

it 'should not pancake xmpp scheme URIs' do
PostRank::URI.parse('xmpp:void(0);').scheme.should == 'xmpp'
end
end
end

0 comments on commit f1a6cf7

Please sign in to comment.