lib/Dhalang/url_utils.rb in Dhalang-0.7.1 vs lib/Dhalang/url_utils.rb in Dhalang-0.7.2
- old
+ new
@@ -4,11 +4,12 @@
# Raises an error if the given URL cannot be used for navigation with Puppeteer.
#
# @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
\ No newline at end of file
+end