about summary refs log tree commit diff
path: root/app/validators
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2023-01-05 13:33:33 +0100
committerGitHub <noreply@github.com>2023-01-05 13:33:33 +0100
commit3654c945832405267e80fe24b14f7e1d74c395ba (patch)
treef3b1a1c11eae7551e0d2a4862f4d99c92cf18cb5 /app/validators
parentb3ab0014e669e25b984dc7e769a2d1e6d2736ef0 (diff)
Strip spaces around URL when adding a relay (#22655)
* Strip spaces around URL when adding a relay

Fixes #22650

* Gracefuly handle URL parsing errors in URL validator
Diffstat (limited to 'app/validators')
-rw-r--r--app/validators/url_validator.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/app/validators/url_validator.rb b/app/validators/url_validator.rb
index 75d1edb87..a90fb6958 100644
--- a/app/validators/url_validator.rb
+++ b/app/validators/url_validator.rb
@@ -10,5 +10,7 @@ class URLValidator < ActiveModel::EachValidator
   def compliant?(url)
     parsed_url = Addressable::URI.parse(url)
     parsed_url && %w(http https).include?(parsed_url.scheme) && parsed_url.host
+  rescue Addressable::URI::InvalidURIError
+    false
   end
 end