preadly-bulbasaur 0.6.0 → 0.6.1

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c7517dcff737c25c17adfa27642bca8ca1cd56e
4
- data.tar.gz: 577969cc263ffc3fa5ddc98de2acf1a38e27e828
3
+ metadata.gz: 40b514207389a8d48e89d57e1368bdf5c05db0dd
4
+ data.tar.gz: 8ec55684674c1587f0a6ecf7a1d851a182683977
5
5
  SHA512:
6
- metadata.gz: 9e758c122332ab66128caf1a94ddce111ac1e634d84dd11bd3e7df68d76be3e340b4b51cfd392ff5ba43407ea5a4fd00c519ebd3801082d6d5aa112a9a91403b
7
- data.tar.gz: ab56e8c804283854aedde3cf02851e5e3cc40b8e720c777955b6506fd776cbf618054bda87286a570ba272b9ac34110bf8741fc663fa3b8ba07f55a34c8246f2
6
+ metadata.gz: 27980ae974932ced7c96047c3f4811df95d54fea82d481776b43f933a2979f3ed736fa2aab25fa378632a7040f762019677688a9ef3bce0c93e9d8d1d2eceab0
7
+ data.tar.gz: 64a1c0ccfd39f8bfe3d68bda43a28d8518741cfbc5107fbcc5060ad79e6fc8d45be734384b1dff7c041fa6317d1f8e8497c0964ac987cbbdc5064f434042dbca
@@ -1,21 +1,15 @@
1
1
  module Bulbasaur
2
-
3
2
  class NormalizeURL
4
-
5
3
  def initialize(base_url, context_url)
6
4
  @base_url = base_url
7
5
  @context_url = context_url
8
6
  end
9
7
 
10
8
  def call
11
- if @context_url =~ /^https?:\/\//
12
- URI::encode @context_url
13
- else
14
- URI::join(@base_url, @context_url).to_s
15
- end
9
+ url = (@context_url =~ /^https?:\/\//) ? @context_url : URI::join(@base_url, @context_url).to_s
10
+ URI::encode URI::decode url
16
11
  rescue
17
- raise ArgumentError, "Not possible normalize url, check the params [base_url: #{@base_url}, context_url: #{@context_url}]"
12
+ raise ArgumentError, "Unable to normalize URL. Params: [base_url: #{@base_url}, context_url: #{@context_url}]."
18
13
  end
19
-
20
14
  end
21
15
  end
@@ -3,7 +3,7 @@ module Bulbasaur
3
3
  module Version
4
4
  MAJOR = 0
5
5
  MINOR = 6
6
- PATCH = 0
6
+ PATCH = 1
7
7
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
8
8
  end
9
9
 
@@ -45,6 +45,14 @@ RSpec.describe Bulbasaur::NormalizeURL do
45
45
  end
46
46
  end
47
47
 
48
+ context 'When using an encoded URL' do
49
+ let(:context_url) { 'http://www.test.com/Hello%C3%A7a_9.jpg~original' }
50
+
51
+ it 'returns the normalized URL' do
52
+ expect(subject).to eq 'http://www.test.com/Hello%C3%A7a_9.jpg~original'
53
+ end
54
+ end
55
+
48
56
  context "When use url not normalized with slash on base: hello.jpg" do
49
57
 
50
58
  let(:base_url) do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: preadly-bulbasaur
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Magno Costa