diff --git a/src/Imgix/UrlBuilder.php b/src/Imgix/UrlBuilder.php index a766a09..aef9099 100644 --- a/src/Imgix/UrlBuilder.php +++ b/src/Imgix/UrlBuilder.php @@ -15,7 +15,7 @@ class UrlBuilder { // constants cannot be dynamically assigned; keeping as a class variable instead private $targetWidths; - public function __construct($domain, $useHttps = false, $signKey = "", $includeLibraryParam = true) { + public function __construct($domain, $useHttps = true, $signKey = "", $includeLibraryParam = true) { if (!is_string($domain)) { throw new \InvalidArgumentException("UrlBuilder must be passed a string domain"); diff --git a/tests/Imgix/Tests/UrlBuilderTest.php b/tests/Imgix/Tests/UrlBuilderTest.php index b288bc3..1ef2976 100644 --- a/tests/Imgix/Tests/UrlBuilderTest.php +++ b/tests/Imgix/Tests/UrlBuilderTest.php @@ -20,6 +20,19 @@ public function testExamplePlain() { $this->assertEquals("http://demos.imgix.net/bridge.png?h=100&w=100", $url); } + public function testExamplePlainUsesHttpsByDefault() { + // Test default `UrlBuilder` uses https by default. + // Construct the builder with a `$domain` __only__. + $builder = new UrlBuilder("demos.imgix.net"); + // Use `setIncludeLibraryParam`. + $builder->setIncludeLibraryParam(false); + // Construct a url in accordance with the other tests. + $params = array("w" => 100, "h" => 100); + // Create the url with the specified `$path` and `$params`. + $url = $builder->createURL("bridge.png", $params); + $this->assertEquals("https://demos.imgix.net/bridge.png?h=100&w=100", $url); + } + public function testExamplePlainHttps() { $builder = new UrlBuilder("demos.imgix.net", false, "", false);