addressable icon indicating copy to clipboard operation
addressable copied to clipboard

Improve `origin` support

Open sandstrom opened this issue 7 years ago • 0 comments

Thanks for a great library :boat:

Retrieving origin works:

uri = Addressable::URI.new(:scheme => 'https', :host => 'google.com')
uri.origin #=> "https://google.com"

But setting origin via the hash, or directly, doesn't work:

# desired behaviour
uri = Addressable::URI.new(:origin => 'https://google.com:8080')
uri.port #=> 8080
uri.origin #=> "https://google.com:8080"

# current behaviour
uri = Addressable::URI.new #=> #<Addressable::URI:0x3fc63817e894 URI:>
uri.origin = "http://newexample.com"
# throws Addressable::URI::InvalidURIError: Absolute URI missing hierarchical segment: 'http:'

Addressable::URI.new(:origin => 'https://google.com').to_s == '' # unexpected

This is under version 2.5.1.

sandstrom avatar Sep 23 '17 11:09 sandstrom