Skip to content

Commit 9a828cf

Browse files
committed
✨ The getUrl method now returns a secure url
1 parent 9d62eaa commit 9a828cf

File tree

5 files changed

+30
-3
lines changed

5 files changed

+30
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes to `laravel-cloudinary` will be documented in this file.
44

5+
## 0.3.0 - 2021-06-02
6+
7+
- ⚠️ BREAKING CHANGE: Renamed environment variable
8+
`CLOUDINARY_URL_SECURE` to `CLOUDINARY_SECURE_URL`
9+
- The `getUrl` method now returns a secure url
10+
511
## 0.2.0 - 2021-06-01
612

713
- Added additional configuration with folder and preset

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ configuration:
3434
'api_key' => env('CLOUDINARY_API_KEY'),
3535
'api_secret' => env('CLOUDINARY_API_SECRET'),
3636
'url' => [
37-
'secure' => env('CLOUDINARY_URL_SECURE', true),
37+
'secure' => (bool) env('CLOUDINARY_SECURE_URL', true),
3838
],
3939
],
4040

config/flysystem-cloudinary.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,17 @@
2828

2929
'folder' => env('CLOUDINARY_FOLDER'),
3030

31+
/*
32+
|--------------------------------------------------------------------------
33+
| Cloudinary Secure URL
34+
|--------------------------------------------------------------------------
35+
|
36+
| This value determines that the asset delivery is forced to use HTTPS
37+
| URLs. If disabled all your assets will be delivered as HTTP URLs.
38+
| Please do not use unsecure URLs in your production application.
39+
|
40+
*/
41+
42+
'secure_url' => (bool) env('CLOUDINARY_SECURE_URL', true),
43+
3144
];

src/FlysystemCloudinaryAdapter.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,14 @@ public function getUrl(string $path): string | false
455455

456456
event(new FlysystemCloudinaryResponseLog($response));
457457

458-
['url' => $url] = $response->getArrayCopy();
458+
[
459+
'url' => $url,
460+
'secure_url' => $secure_url,
461+
] = $response->getArrayCopy();
462+
463+
if (config('flysystem-cloudinary.secure_url')) {
464+
return $secure_url;
465+
}
459466

460467
return $url;
461468
}

tests/Feature/FlysystemCloudinaryAdapterTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public function it_can_read_stream()
252252

253253
$meta = $this->adapter->readStream($publicId);
254254

255-
$this->assertIsString($meta['stream']);
255+
$this->assertIsResource($meta['stream']);
256256
$this->assertArrayNotHasKey('contents', $meta);
257257
$this->adapter->delete($publicId); // cleanup
258258
}
@@ -400,6 +400,7 @@ public function it_does_get_url()
400400

401401
$url = $this->adapter->getUrl($publicId);
402402

403+
$this->assertStringStartsWith('https://', $url);
403404
$this->assertStringContainsString($publicId, $url);
404405
$this->adapter->delete($publicId); // cleanup
405406
}

0 commit comments

Comments
 (0)