From 7086aa598b95257ddf9b268efb58bdad7572350c Mon Sep 17 00:00:00 2001 From: Shuhei Kitagawa Date: Sun, 10 Jun 2018 05:47:50 +0900 Subject: Add tests for intents_controller (#7763) --- app/controllers/intents_controller.rb | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'app/controllers/intents_controller.rb') 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 -- cgit