diff --git a/app/models/relay.rb b/app/models/relay.rb
index d6ddd30ede42c439b498a6fd5d70c2895c2b8395..c66bfe4ffe1ce70868f5aaacb095bf2e72bc1619 100644
--- a/app/models/relay.rb
+++ b/app/models/relay.rb
@@ -18,6 +18,7 @@ class Relay < ApplicationRecord
 
   scope :enabled, -> { accepted }
 
+  before_validation :strip_url
   before_destroy :ensure_disabled
 
   alias enabled? accepted?
@@ -74,4 +75,8 @@ class Relay < ApplicationRecord
   def ensure_disabled
     disable! if enabled?
   end
+
+  def strip_url
+    inbox_url&.strip!
+  end
 end
diff --git a/app/validators/url_validator.rb b/app/validators/url_validator.rb
index 75d1edb873932b07bb56e4d0d75e79f0f694d766..a90fb6958a66e11d0b63097aa3b26bb29134b6e8 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