Browse Source

Check if the query is nil when using the address-search api

pull/2981/head
Manny Dinssa 2 months ago
parent
commit
f4356168b4
  1. 4
      app/controllers/address_search_controller.rb

4
app/controllers/address_search_controller.rb

@ -5,7 +5,9 @@ class AddressSearchController < ApplicationController
def index
query = params[:query]
if query.match?(/\A\d+\z/) && query.length > 5
if query.nil?
render json: { error: "Query cannot be blank." }, status: :bad_request
elsif query.match?(/\A\d+\z/) && query.length > 5
# Query is all numbers and greater than 5 digits, assume it's a UPRN
service = UprnClient.new(query)
service.call

Loading…
Cancel
Save