redirect_follow_get 0.1.0 → 0.2.0

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
  SHA1:
3
- metadata.gz: 7d0db72754f1f88f20f6354c5df5e2793a3c5711
4
- data.tar.gz: c1f31d200f4f3bf603473e963b8855b39d2079af
3
+ metadata.gz: a831dd9b5e01723a9bf1004b0c7d7a5424b95ab5
4
+ data.tar.gz: 5e45066b9389e50157be7101b1e9e7ad29746c5d
5
5
  SHA512:
6
- metadata.gz: 0656efe9317891d71c395ba54f0dcc5da93dd88c3659677a9d88ef07f8113f6f51a970ff43928dc07bee8651210a95c174fb98d745a37f843bb5919bd9ab8b0d
7
- data.tar.gz: 64ea680fc9c6b93874b280d4267dbd52d30ccfb3157381122d8df94d3db780e1c80653d09455d4eefe35e9f62e902ffdcc8f864bef26916b3a438cf54a4ca859
6
+ metadata.gz: 8386e482f4590153095730a8dcdbfbaa08ca58f73ff16d7f571f09455decc51c9487af4d9583a9abb254da0ee56e8913ae52938f89d2dc06c6929e90a30778e0
7
+ data.tar.gz: 7ceb67ec8742f4bbbb8ec669696b8f88adc9171360f01383f02850d77209e728ce84a686e256d73fd3e71ebdf05747091a38ffb637f95e5007eabcc93ff21ef0
@@ -7,8 +7,5 @@ require "redirect_follow_get"
7
7
  # with your gem easier. You can also use a different console, if you like.
8
8
 
9
9
  # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start
10
+ require "pry"
11
+ Pry.start
@@ -6,18 +6,16 @@ require 'net/http'
6
6
  module RedirectFollowGet
7
7
  class TooManyRedirects < StandardError; end
8
8
 
9
- def self.parse_url(url)
10
- return URI.parse(url) if url.ascii_only?
11
- Addressable::URI.parse(url).normalize
12
- rescue URI::InvalidURIError
13
- # if InvalidURIError is raised in URI.parse(),
14
- # fallback to Addressable::URI.parse() method.
15
- Addressable::URI.parse(url).normalize
9
+ class << self
10
+ def parse_url(url)
11
+ url = Addressable::URI.parse(url).normalize.to_s unless url.ascii_only?
12
+ URI.parse(url)
13
+ end
16
14
  end
17
15
  end
18
16
 
19
17
  def redirect_follow_get(url, limit: 10)
20
- raise RedirectFollowGet::TooManyRedirects, 'too many HTTP redirects' if limit.zero?
18
+ raise RedirectFollowGet::TooManyRedirects, 'too many HTTP redirects' unless limit > 0
21
19
 
22
20
  uri = RedirectFollowGet.parse_url(url)
23
21
 
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module RedirectFollowGet
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redirect_follow_get
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toshimaru
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-10 00:00:00.000000000 Z
11
+ date: 2017-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable