Class: Prestashopper::UriHandler
- Inherits:
-
Object
- Object
- Prestashopper::UriHandler
- Defined in:
- lib/prestashopper/uri_handler.rb
Overview
Handle URIs, converting from base Prestashop URL to API URIs
Constant Summary collapse
- API_PATH =
'api/'
Class Method Summary collapse
-
.api_uri(base_url) ⇒ String
Convert a base Prestashop URL to its API URI.
Class Method Details
.api_uri(base_url) ⇒ String
Convert a base Prestashop URL to its API URI
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/prestashopper/uri_handler.rb', line 14 def self.api_uri(base_url) # Base URL must end in '/' so that we can properly append other path fragments for the API paths base_url.strip! base_url += '/' unless base_url[-1] == '/' # Add http:// scheme if the scheme is missing from the base url base_url = 'http://' + base_url if URI.parse(base_url).scheme.nil? uri = URI.join base_url, API_PATH return uri.to_s end |