Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use URI methods to validate URLs instead of patterns #70

Merged
merged 3 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
PATH
remote: .
specs:
Dhalang (0.7.1)
Dhalang (0.7.2)

GEM
remote: https://rubygems.org/
specs:
Ascii85 (1.1.0)
Ascii85 (1.1.1)
afm (0.2.2)
bigdecimal (3.1.7)
bigdecimal (3.1.8)
diff-lcs (1.5.1)
fastimage (2.2.7)
hashery (2.1.2)
Expand All @@ -23,15 +23,15 @@ GEM
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.0)
rspec-core (3.13.2)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.0)
rspec-expectations (3.13.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.0)
rspec-mocks (3.13.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.1)
rspec-support (3.13.2)
ruby-rc4 (0.1.5)
ttfunk (1.8.0)
bigdecimal (~> 3.1)
Expand Down
9 changes: 5 additions & 4 deletions lib/Dhalang/url_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ class UrlUtils
#
# @param [String] url The url to validate
def self.validate(url)
if (url !~ URI::DEFAULT_PARSER.regexp[:ABS_URI])
raise URI::InvalidURIError, 'The given url was invalid, use format http://www.example.com'
end
parsed = URI.parse(url) # Raise URI::InvalidURIError on invalid URLs
return true if parsed.absolute?

raise URI::InvalidURIError, 'The given url was invalid, use format http://www.example.com'
end
end
end
end
2 changes: 1 addition & 1 deletion lib/Dhalang/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Dhalang
VERSION = "0.7.1"
VERSION = "0.7.2"
end
Loading