From 442b4a241bf03a8e96fd6395fec2e1d64d65e869 Mon Sep 17 00:00:00 2001
From: gregoirenovel <log@kinko.fr>
Date: Mon, 15 Oct 2018 16:38:17 +0200
Subject: [PATCH] Make API_ADRRESSE_URL canonical

---
 app/lib/api_adresse/driver.rb | 4 +++-
 config/initializers/urls.rb   | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/app/lib/api_adresse/driver.rb b/app/lib/api_adresse/driver.rb
index 37c8ed00b..fadcfb2af 100644
--- a/app/lib/api_adresse/driver.rb
+++ b/app/lib/api_adresse/driver.rb
@@ -8,7 +8,9 @@ module ApiAdresse
     end
 
     def call
-      RestClient.get(API_ADRESSE_URL, params: { q: @address, limit: @limit })
+      search_url = [API_ADRESSE_URL, "search"].join("/")
+
+      RestClient.get(search_url, params: { q: @address, limit: @limit })
     rescue RestClient::ServiceUnavailable
       nil
     end
diff --git a/config/initializers/urls.rb b/config/initializers/urls.rb
index c8a8e0900..c5d3c2703 100644
--- a/config/initializers/urls.rb
+++ b/config/initializers/urls.rb
@@ -1,5 +1,5 @@
 # API URLs
-API_ADRESSE_URL = "https://api-adresse.data.gouv.fr/search"
+API_ADRESSE_URL = "https://api-adresse.data.gouv.fr"
 API_CARTO_URL = "https://apicarto.sgmap.fr"
 API_ENTREPRISE_URL = "https://entreprise.api.gouv.fr/v2"
 API_GEO_URL = "https://geo.api.gouv.fr"