about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorShuhei Kitagawa <shuheiktgw@users.noreply.github.com>2018-06-10 05:47:50 +0900
committerEugen Rochko <eugen@zeonfederated.com>2018-06-09 22:47:50 +0200
commit7086aa598b95257ddf9b268efb58bdad7572350c (patch)
tree394ffe47ca3a48f8011d1acbe6566537bd6507be /app
parent10f51c9886123982bc9f2a95fba39dd1f24b9a05 (diff)
Add tests for intents_controller (#7763)
Diffstat (limited to 'app')
-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