absolution 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +1 -0
- data/lib/absolution/version.rb +1 -1
- data/lib/absolution.rb +8 -5
- data/spec/absolution_spec.rb +10 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NjEyN2VhZDI3ZGM5OWZiZjMwOWQ3NzhhOWFmM2ViNDZjY2RlM2NlMg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NDE2YzVkMTZkMDI4YmVhMjhkOTUwYjkwOGQ1MWM2ZWYzNjVhYjcxOA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MWViZDMyMmE5MzU4ZmNiZWJjNTE4OGM2OTY5MjdjZTFlOGM5YzMzNzIxZjdj
|
10
|
+
YTY1YzM3NWJiM2U5Yzg3MjU4NzAxYzBjZDYzZDExZTQzMGVkNTAzZWFjYzZh
|
11
|
+
Yjc0ZDg2N2QwMjU2M2NiZDViNWNmZTQ5YzE2NmRlMWMwNjE3MjY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Y2NlMWE5ZTRhZDVmZWIzNjlmYzBkMDBjOWY4OGVjYmM4ZDE4MmI5M2QxM2Zi
|
14
|
+
NzU3YzEzNzRlMjRmNWY4YjQ4NmYzMjcyY2FkYTdmYWJmOWQ5ZmQ5M2Q2ODUz
|
15
|
+
ZTczOTQ4ZDUxMzE2MTAxMjRmZDE0ZmE1ZWE3OTQwNTgyMGY5YTg=
|
data/README.md
CHANGED
data/lib/absolution/version.rb
CHANGED
data/lib/absolution.rb
CHANGED
@@ -7,12 +7,15 @@ module Absolution
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def construct_absolute_url(base_url, path)
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
uri = URI.parse(base_url)
|
11
|
+
|
12
|
+
URI.parse(path.start_with?('/') ? path : "/#{path}").tap do |path_uri|
|
13
|
+
uri.path = path_uri.path
|
14
|
+
uri.query = path_uri.query
|
15
|
+
uri.fragment = path_uri.fragment
|
14
16
|
end
|
15
|
-
|
17
|
+
|
18
|
+
uri.to_s
|
16
19
|
end
|
17
20
|
|
18
21
|
extend self
|
data/spec/absolution_spec.rb
CHANGED
@@ -34,13 +34,14 @@ describe Absolution do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
describe '.construct_absolute_url' do
|
37
|
+
let(:base_url) {'http://fake.url'}
|
38
|
+
|
37
39
|
it 'combines a base url with a path' do
|
38
40
|
expect(klass.construct_absolute_url('http://fake.url', '/asset.file')).
|
39
41
|
to eql('http://fake.url/asset.file')
|
40
42
|
end
|
41
43
|
|
42
44
|
it 'separates the base url from the asset with at least 1 /' do
|
43
|
-
base_url = 'http://fake.url'
|
44
45
|
asset_path = 'asset.file'
|
45
46
|
expected_url = base_url + '/' + asset_path
|
46
47
|
expect(klass.construct_absolute_url(base_url, asset_path)).
|
@@ -48,20 +49,25 @@ describe Absolution do
|
|
48
49
|
end
|
49
50
|
|
50
51
|
it 'removes an extra / when both the base url and the asset path have it' do
|
51
|
-
base_url = 'http://fake.url/'
|
52
52
|
asset_path = '/asset.file'
|
53
53
|
expected_url = base_url.chomp('/') + asset_path
|
54
|
-
expect(klass.construct_absolute_url(base_url, asset_path)).
|
54
|
+
expect(klass.construct_absolute_url(base_url + '/', asset_path)).
|
55
55
|
to eql(expected_url)
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'handles query strings appropriately' do
|
59
|
-
base_url = 'http://fake.url'
|
60
59
|
asset_path = '/asset.file?key=val'
|
61
60
|
expected_url = base_url + asset_path
|
62
61
|
expect(klass.construct_absolute_url(base_url, asset_path)).
|
63
62
|
to eql(expected_url)
|
64
63
|
end
|
64
|
+
|
65
|
+
it 'handles fragments appropriately' do
|
66
|
+
asset_path = '#fortytwo'
|
67
|
+
expected_url = base_url + '/' + asset_path
|
68
|
+
expect(klass.construct_absolute_url(base_url, asset_path)).
|
69
|
+
to eql(expected_url)
|
70
|
+
end
|
65
71
|
end
|
66
72
|
end
|
67
73
|
|