From b25f08f2e996685364ee72825918680c8fbf1400 Mon Sep 17 00:00:00 2001 From: Chris Page Date: Fri, 23 Jan 2026 16:10:44 +0000 Subject: [PATCH] Added pullzone URL to temporaryUrl generation --- src/BunnyCDNAdapter.php | 7 ++----- tests/TemporaryUrlTest.php | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/BunnyCDNAdapter.php b/src/BunnyCDNAdapter.php index a1c81b6..7301c35 100644 --- a/src/BunnyCDNAdapter.php +++ b/src/BunnyCDNAdapter.php @@ -582,14 +582,14 @@ public function temporaryUrl(string $path, DateTimeInterface $expiresAt, Config // extract elements from our path $parts = parse_url($path); - $path = $parts['path']; + $path = str_starts_with($parts['path'], '/') ? $path : '/'.$path; // extract our query params parse_str($parts['query'] ?? '', $params); ksort($params); // concatenate all of our data - return $path + return $this->pullzone_url.$path .(str_contains($path, '?') ? '&' : '?') .'token='.$this->buildSigningKey($path, $expiration, $params) .'&expires='.$expiration @@ -598,9 +598,6 @@ public function temporaryUrl(string $path, DateTimeInterface $expiresAt, Config private function buildSigningKey($path, int $expiration, array $params): string { - // prefix our path - $path = str_starts_with($path, '/') ? $path : '/'.$path; - // process our query params $query = implode('&', array_map(fn ($k, $v) => $k.'='.$v, array_keys($params), $params)); diff --git a/tests/TemporaryUrlTest.php b/tests/TemporaryUrlTest.php index 4c25cb0..6fe9065 100644 --- a/tests/TemporaryUrlTest.php +++ b/tests/TemporaryUrlTest.php @@ -25,13 +25,13 @@ public function test_temporary_url_throws_exception_if_not_configured() public function test_it_can_generate_signing_key() { $client = new BunnyCDNClient('test', 'test'); - $adapter = new BunnyCDNAdapter($client, 'pz-key'); + $adapter = new BunnyCDNAdapter($client, 'https://pz-url.co.uk'); $adapter->setTokenAuthKey('test-auth-key'); $expiresAt = new \DateTimeImmutable('+1 hour'); $url = $adapter->temporaryUrl('testing.txt', $expiresAt, new Config()); - $this->assertStringContainsString('testing.txt?token=', $url); + $this->assertStringContainsString('https://pz-url.co.uk/testing.txt?token=', $url); $this->assertStringContainsString('expires='.$expiresAt->getTimestamp(), $url); } }