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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/uri/builder/version.rb +1 -1
- data/lib/uri/builder.rb +13 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d90c9dfcbf3a15504e21d45d26a2c61878aebcd7571d18e07ad8782370011195
|
4
|
+
data.tar.gz: d25487607b08a42ae363681724ac0190fef6a522771ad06ba686c908e65529ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 661d6acf1e0d8e37543d0bf8a02c7a7964e453c9e55e074c03aed13010bb51ca236b846a6eb017bf8831ea09d866e16cfbf0084b6525bf8e23e930d2df59bac7
|
7
|
+
data.tar.gz: ef46b356e3770bd5ccf7e1eea45d02eb700b913e1b019c7fc0bd651238b1d5b0c7a760775d1f6ca581081714597702fe3cc1609258ce167a2c3989c4e519ee02
|
data/Gemfile.lock
CHANGED
data/lib/uri/builder/version.rb
CHANGED
data/lib/uri/builder.rb
CHANGED
@@ -21,9 +21,19 @@ module URI
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def scheme(value)
|
24
|
-
|
25
|
-
|
26
|
-
|
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)
|