Skip to content

Commit

Permalink
Update the logic for finding
Browse files Browse the repository at this point in the history
Fix. Host Extraction Logic To Handle original_url Safely
  • Loading branch information
bodhish authored Oct 16, 2024
2 parents 181dc36 + a5f78a2 commit 8b1bb6c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions app/controllers/api/v1/templates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 8b1bb6c

Please sign in to comment.