uri-builder 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bfc6aae28ed080b625a086509de8d8f540c7b96ae18fd44ac5e9206a116160c4
4
- data.tar.gz: 55094b5b4f3e05475b9fea762c6abad86a8665c3e817b0ba17ed264f795b5b06
3
+ metadata.gz: d90c9dfcbf3a15504e21d45d26a2c61878aebcd7571d18e07ad8782370011195
4
+ data.tar.gz: d25487607b08a42ae363681724ac0190fef6a522771ad06ba686c908e65529ea
5
5
  SHA512:
6
- metadata.gz: 120a8ea8dbd40db58885acbd69aa2dd7c6a53f1dab53facc44d3e7415efb9568470e83798156359bccc8a87a5d289426d94fefca7f62fb7aff73d010bb8079a4
7
- data.tar.gz: 4284aa8a800bd0f92156ee916dd087c1194f776291afdfc7204e17f532bb96efc97414ab72fba4193101b8a5e7816ce391218dcd80a4465c8eadb7ae95dbe94c
6
+ metadata.gz: 661d6acf1e0d8e37543d0bf8a02c7a7964e453c9e55e074c03aed13010bb51ca236b846a6eb017bf8831ea09d866e16cfbf0084b6525bf8e23e930d2df59bac7
7
+ data.tar.gz: ef46b356e3770bd5ccf7e1eea45d02eb700b913e1b019c7fc0bd651238b1d5b0c7a760775d1f6ca581081714597702fe3cc1609258ce167a2c3989c4e519ee02
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- uri-builder (0.1.3)
4
+ uri-builder (0.1.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -2,6 +2,6 @@
2
2
 
3
3
  module URI
4
4
  module Build
5
- VERSION = "0.1.3"
5
+ VERSION = "0.1.4"
6
6
  end
7
7
  end
data/lib/uri/builder.rb CHANGED
@@ -21,9 +21,19 @@ module URI
21
21
  end
22
22
 
23
23
  def scheme(value)
24
- target_scheme = URI.scheme_list[value.upcase]
25
- args = Hash[target_scheme.component.map { |attr| [ attr, @uri.send(attr) ] }]
26
- @uri = target_scheme.build(**args)
24
+ if @uri.scheme
25
+ # Handles URLs without schemes, like https://example.com/foo
26
+ target_scheme = URI.scheme_list[value.upcase]
27
+ args = Hash[target_scheme.component.map { |attr| [ attr, @uri.send(attr) ] }]
28
+ @uri = target_scheme.build(**args)
29
+ else
30
+ # Handles URLs without schemes, like example.com/foo
31
+ uri = URI.parse("#{value}://#{@uri.path}")
32
+ (uri.component - %i[host path scheme]).each do |component|
33
+ uri.send "#{component}=", @uri.send(component)
34
+ end
35
+ @uri = uri
36
+ end
27
37
  end
28
38
 
29
39
  def query(value)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uri-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brad Gessler