about summary refs log tree commit diff
path: root/app/controllers/intents_controller.rb
diff options
context:
space:
mode:
authorDavid Yip <yipdw@member.fsf.org>2018-06-12 18:12:29 -0500
committerGitHub <noreply@github.com>2018-06-12 18:12:29 -0500
commitf6bb50b6ece555af138df164680189b1ec57da4b (patch)
tree490c6054260f4a75fb0467f343124746c1935970 /app/controllers/intents_controller.rb
parent34f1fd2a621ca869c17009487e2f10063812fbd0 (diff)
parentfac6e392e9d76e3cca44ce142690a59afc0a9156 (diff)
Merge pull request #539 from glitch-soc/merge-upstream
Merge upstream
Diffstat (limited to 'app/controllers/intents_controller.rb')
-rw-r--r--app/controllers/intents_controller.rb19
1 files changed, 17 insertions, 2 deletions
diff --git a/app/controllers/intents_controller.rb b/app/controllers/intents_controller.rb
index 504befd1f..56129d69a 100644
--- a/app/controllers/intents_controller.rb
+++ b/app/controllers/intents_controller.rb
@@ -1,9 +1,10 @@
 # frozen_string_literal: true
 
 class IntentsController < ApplicationController
-  def show
-    uri = Addressable::URI.parse(params[:uri])
+  before_action :check_uri
+  rescue_from Addressable::URI::InvalidURIError, with: :handle_invalid_uri
 
+  def show
     if uri.scheme == 'web+mastodon'
       case uri.host
       when 'follow'
@@ -15,4 +16,18 @@ class IntentsController < ApplicationController
 
     not_found
   end
+
+  private
+
+  def check_uri
+    not_found if uri.blank?
+  end
+
+  def handle_invalid_uri
+    not_found
+  end
+
+  def uri
+    @uri ||= Addressable::URI.parse(params[:uri])
+  end
 end