Skip to content

Commit 229b4ce

Browse files
authored
fix: flatten nested array in $params (#40)
1 parent e192dbd commit 229b4ce

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/Imgix/UrlHelper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function getURL() {
7171
if (substr($key, -2) == '64') {
7272
$encodedVal = self::base64url_encode($val);
7373
} else {
74-
$encodedVal = rawurlencode($val);
74+
$encodedVal = is_array($val) ? rawurlencode(implode(',',$val)) : rawurlencode($val);
7575
}
7676

7777
$queryPairs[] = rawurlencode($key) . "=" . $encodedVal;

tests/Imgix/Tests/UrlBuilderTest.php

+7
Original file line numberDiff line numberDiff line change
@@ -124,5 +124,12 @@ public function testInclusionOfLibraryVersionParam() {
124124

125125
$this->assertEquals("https://demos.imgix.net/https%3A%2F%2Fmy-demo-site.com%2Ffiles%2F133467012%2Favatar%20icon.png%3Fsome%3Dchill%26params%3D1?ixlib=php-" . $version, $url);
126126
}
127+
public function testNestedParameters(){
128+
$builder = new UrlBuilder("demos.imgix.net", true, "", ShardStrategy::CRC, false);
129+
$params = array("auto" => array("compress","format"));
130+
$url = $builder->createURL("bridge.png", $params);
131+
132+
$this->assertEquals("https://demos.imgix.net/bridge.png?auto=compress%2Cformat", $url);
133+
}
127134
}
128135
?>

0 commit comments

Comments
 (0)