diff --git a/src/BCLib/PrimoServices/Availability/AlmaClient.php b/src/BCLib/PrimoServices/Availability/AlmaClient.php index 40bc59d..e9bb19c 100644 --- a/src/BCLib/PrimoServices/Availability/AlmaClient.php +++ b/src/BCLib/PrimoServices/Availability/AlmaClient.php @@ -31,7 +31,12 @@ class AlmaClient implements AvailabilityClient public function __construct(Client $client, $alma_host, $library) { $this->client = $client; - $this->alma_host = $alma_host; + + if (strpos($alma_host, 'http://') === 0 || strpos($alma_host, 'https://') === 0) { + $this->alma_host = $alma_host; + } else { + $this->alma_host = 'http://' . $alma_host; + } $this->library = $library; $this->ava_map = [ @@ -90,7 +95,7 @@ private function buildUrl($ids) 'library' => $this->library ] ); - return "http://{$this->alma_host}/view/publish_avail?$query"; + return "{$this->alma_host}/view/publish_avail?$query"; } /** @@ -155,4 +160,4 @@ private function fetchAvailability(array $components) $response = $this->client->get($url)->send(); return simplexml_load_string($response->getBody(true)); } -} \ No newline at end of file +} diff --git a/src/BCLib/PrimoServices/PrimoServices.php b/src/BCLib/PrimoServices/PrimoServices.php index 7e74995..40a893d 100644 --- a/src/BCLib/PrimoServices/PrimoServices.php +++ b/src/BCLib/PrimoServices/PrimoServices.php @@ -38,7 +38,12 @@ public function __construct( $version = '4.9', array $ignore_errors = [] ) { - $this->_host = $host; + if (strpos($host, 'http://') === 0 || strpos($host, 'https://') === 0) { + $this->_host = $host; + } else { + $this->_host = 'http://' . $host; + } + $this->_institution = $institution; if (null === $cache) { $this->_cache = new NullCache(); @@ -198,7 +203,7 @@ public function createDeepLink() */ public function url($action, $query_string) { - return "http://{$this->_host}/PrimoWebServices/xservice/search/$action?json=true&$query_string"; + return "{$this->_host}/PrimoWebServices/xservice/search/$action?json=true&$query_string"; } public function getHost() {