From b68f44cd7b9f6862ce726558a5c2ef3c040c2113 Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Wed, 7 Sep 2022 10:49:49 +0100 Subject: [PATCH] feat: add coping with nil add_another_location query string --- app/controllers/locations_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/locations_controller.rb b/app/controllers/locations_controller.rb index 2bb9d6c89..f57fb6b4d 100644 --- a/app/controllers/locations_controller.rb +++ b/app/controllers/locations_controller.rb @@ -70,7 +70,9 @@ class LocationsController < ApplicationController when "edit-name" redirect_to(scheme_check_answers_path(@scheme, anchor: "locations")) when "edit-local-authority" - @add_another_location = nil&.(CGI.parse(URI.parse(request.referrer).query)['add_another_location'].first) + @uri_query = URI.parse(request.referer).query + @query_hash = @uri_query ? CGI.parse(@uri_query) : { "add_another_location": [] } + @add_another_location = @query_hash["add_another_location"].try(:first) if @add_another_location == "Yes" redirect_to(new_location_path(@location.scheme)) else