absolution 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NjEyN2VhZDI3ZGM5OWZiZjMwOWQ3NzhhOWFmM2ViNDZjY2RlM2NlMg==
4
+ MjA0ZTc4NmNmNTU0NmMxZjMzODFjYTdhZmZmNTU4OWVkY2RhNGUwZg==
5
5
  data.tar.gz: !binary |-
6
- NDE2YzVkMTZkMDI4YmVhMjhkOTUwYjkwOGQ1MWM2ZWYzNjVhYjcxOA==
6
+ YmI2OWM4MGViZGE4ZGVmNzIzMjA4ODA5NjUxNmE4YjRiNzI2ZjhkZg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MWViZDMyMmE5MzU4ZmNiZWJjNTE4OGM2OTY5MjdjZTFlOGM5YzMzNzIxZjdj
10
- YTY1YzM3NWJiM2U5Yzg3MjU4NzAxYzBjZDYzZDExZTQzMGVkNTAzZWFjYzZh
11
- Yjc0ZDg2N2QwMjU2M2NiZDViNWNmZTQ5YzE2NmRlMWMwNjE3MjY=
9
+ YTMyNmEzMGY4MzYzZmJlMTJkNTJmYzBhMWU3NWQ3ZGNhZTAyNTdkZGU2YTVm
10
+ NWJkZDMzMDRiMmZlZWY5MzM1YmFjNDkyNzQxYWQ3ZDE0NjYxOWNiYzU2MWE1
11
+ Yzk4NzI1N2MyY2UwOTgwYTAyOTFlOWY4YzQ1ZTNkNjdiNmRkMzk=
12
12
  data.tar.gz: !binary |-
13
- Y2NlMWE5ZTRhZDVmZWIzNjlmYzBkMDBjOWY4OGVjYmM4ZDE4MmI5M2QxM2Zi
14
- NzU3YzEzNzRlMjRmNWY4YjQ4NmYzMjcyY2FkYTdmYWJmOWQ5ZmQ5M2Q2ODUz
15
- ZTczOTQ4ZDUxMzE2MTAxMjRmZDE0ZmE1ZWE3OTQwNTgyMGY5YTg=
13
+ NzNkYmU3YjYxZTBhMWVkMzI3ZTQ4MGY4NjUyZWVjMDM4MGYzZGY4NGNiNDE1
14
+ ODE1ZTU0MjYyYjUyYjc4YmJkZTkzZTAwMTA3MWVhMGNlZjhlMTk4MTk4MDQ1
15
+ MTljMzI3MjI5ZjU3NzY2OGUwYjAxYWNlNGYxYTUyZGMxYzRmZmI=
data/README.md CHANGED
@@ -30,6 +30,9 @@ Absolution.absolute_url?('http://blah')
30
30
 
31
31
  Absolution.construct_absolute_url('https://base.url', 'blah')
32
32
  => 'https://base.url/blah'
33
+
34
+ Absolution.construct_absolue_url('http://base.url/path/to/namespace', 'blah')
35
+ => 'http://base.url/path/to/namespace/blah'
33
36
  ```
34
37
 
35
38
  ## Other usage (mixin) ##
@@ -60,6 +63,7 @@ Do you use git-flow? I sure do. Please base anything you do off of
60
63
 
61
64
  ## History ##
62
65
 
66
+ * 0.0.6 - Handle path in base URL
63
67
  * 0.0.5 - Better relative path handling
64
68
  * 0.0.4 - Query strings are handled properly
65
69
  * 0.0.2 - Initial release
@@ -2,15 +2,14 @@ require 'uri'
2
2
  module Absolution
3
3
 
4
4
  def absolute_url?(url)
5
- scheme = URI.parse(url.to_s).scheme
6
- !(scheme.nil? || scheme.empty?)
5
+ URI.parse(url.to_s).absolute?
7
6
  end
8
7
 
9
8
  def construct_absolute_url(base_url, path)
10
9
  uri = URI.parse(base_url)
11
10
 
12
11
  URI.parse(path.start_with?('/') ? path : "/#{path}").tap do |path_uri|
13
- uri.path = path_uri.path
12
+ uri.path = uri.path.chomp('/') + path_uri.path
14
13
  uri.query = path_uri.query
15
14
  uri.fragment = path_uri.fragment
16
15
  end
@@ -1,3 +1,3 @@
1
1
  module Absolution
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
@@ -41,6 +41,13 @@ describe Absolution do
41
41
  to eql('http://fake.url/asset.file')
42
42
  end
43
43
 
44
+ it 'handles a base url with an existing path component' do
45
+ extended_base_url = 'http://fake.url/base/path'
46
+ asset_path = 'asset.file'
47
+ expect(klass.construct_absolute_url(extended_base_url, asset_path)).
48
+ to eql(extended_base_url + '/' + asset_path)
49
+ end
50
+
44
51
  it 'separates the base url from the asset with at least 1 /' do
45
52
  asset_path = 'asset.file'
46
53
  expected_url = base_url + '/' + asset_path
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: absolution
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dennis Walters
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-06 00:00:00.000000000 Z
11
+ date: 2014-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec