diff --git a/app/controllers/api/v1/templates_controller.rb b/app/controllers/api/v1/templates_controller.rb index 5d85f5f..d23ae05 100644 --- a/app/controllers/api/v1/templates_controller.rb +++ b/app/controllers/api/v1/templates_controller.rb @@ -25,12 +25,10 @@ def find_by_domain private def find_host(request) - host = request.origin.match(%r{https?://([^/]+)}).captures[0] rescue nil - - return host if host - - return "www.medispeak.in" if request.referer&.include?("medispeak.in") + extract_host(request.origin) || extract_host(request.original_url) + end - nil + def extract_host(url) + url&.match(%r{https?://([^/]+)}).captures[0] rescue nil end end