Skip to content

Commit

Permalink
Merge pull request #5 from yubele/master
Browse files Browse the repository at this point in the history
Fix URI Error
  • Loading branch information
indyarocks authored May 30, 2023
2 parents 6b672e7 + 45df878 commit 28dfde8
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/pkg/
/spec/reports/
/tmp/
/vendor/bundle

# rspec failure tracking
.rspec_status
2 changes: 1 addition & 1 deletion final_redirect_url.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_development_dependency "bundler", "~> 1.14"
spec.add_development_dependency "bundler", "> 1.14"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "rspec", "~> 3.0"
end
2 changes: 1 addition & 1 deletion lib/final_redirect_url.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def self.final_redirect_url(url, options={})

private
def self.is_valid_url?(url)
url.to_s =~ /\A#{URI::regexp(['http', 'https'])}\z/
url.to_s.match? URI::regexp(['http', 'https'])
end

def self.get_final_redirect_url(url, limit = 10)
Expand Down
2 changes: 1 addition & 1 deletion lib/final_redirect_url/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module FinalRedirectUrl
VERSION = "0.1.0"
VERSION = "0.1.1"
end
7 changes: 7 additions & 0 deletions spec/final_redirect_url_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
expect(FinalRedirectUrl::VERSION).not_to be nil
end

context "with truth url" do
it "return truth" do
expect(FinalRedirectUrl.is_valid_url?("http://command-not-found.com")).to be true
expect(FinalRedirectUrl.is_valid_url?("https://build.com")).to be true
end
end

context "with invalid url" do
it "returns error" do
# If invalid URL, returns 404 Not Found
Expand Down

0 comments on commit 28dfde8

Please sign in to comment.