Skip to content

Commit 738e2cb

Browse files
committed
Merge branch 'master' into v3
2 parents dfc747a + 97f34d0 commit 738e2cb

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/BunnyCDNAdapter.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,12 @@ public function temporaryUrl(string $path, DateTimeInterface $expiresAt, Config
586586

587587
// extract our query params
588588
parse_str($parts['query'] ?? '', $params);
589+
590+
// check if we are passing additional query parameters
591+
if (($queryParams = $config->get('withQueryParams')) && is_array($queryParams)) {
592+
$params = array_merge($params, $queryParams);
593+
}
594+
589595
ksort($params);
590596

591597
// concatenate all of our data

tests/TemporaryUrlTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,22 @@ public function test_it_can_generate_signing_key()
3434
$this->assertStringContainsString('https://pz-url.co.uk/testing.txt?token=', $url);
3535
$this->assertStringContainsString('expires='.$expiresAt->getTimestamp(), $url);
3636
}
37+
38+
public function test_it_will_accept_query_params()
39+
{
40+
$client = new BunnyCDNClient('test', 'test');
41+
$adapter = new BunnyCDNAdapter($client, 'https://pz-url.co.uk');
42+
$adapter->setTokenAuthKey('test-auth-key');
43+
44+
$expiresAt = new \DateTimeImmutable('+1 hour');
45+
$url = $adapter->temporaryUrl('testing.txt', $expiresAt, new Config([
46+
'withQueryParams' => [
47+
'testParam' => 'testValue',
48+
],
49+
]));
50+
51+
$this->assertStringContainsString('https://pz-url.co.uk/testing.txt?token=', $url);
52+
$this->assertStringContainsString('expires='.$expiresAt->getTimestamp(), $url);
53+
$this->assertStringContainsString('testParam=testValue', $url);
54+
}
3755
}

0 commit comments

Comments
 (0)