Skip to content

Commit f906cbe

Browse files
committed
➖ refactor: adjust version comparison
1 parent 599fb2a commit f906cbe

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
}
1212
],
1313
"require": {
14-
"laravel/framework": "^9.33.0",
15-
"alphasnow/aliyun-oss-flysystem": "^3.2.10"
14+
"laravel/framework": "^9.0",
15+
"alphasnow/aliyun-oss-flysystem": "^3.2"
1616
},
1717
"require-dev": {
1818
"mockery/mockery": "^1.5",

src/AliyunAdapter.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ class AliyunAdapter extends BaseAdapter
99
public function getUrl(string $path): string
1010
{
1111
// After Laravel v9.33.0 (#44330), path are prefixed
12-
return $this->urlGenerator->fullUrl($path);
12+
$usePrefix = $this->config["use_url_prefix"] ?? false;
13+
if ($usePrefix === false) {
14+
return $this->urlGenerator->fullUrl($path);
15+
}
16+
return parent::getUrl($path);
1317
}
1418
}

src/AliyunServiceProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public function boot()
5454
{
5555
$this->app->make("filesystem")
5656
->extend("oss", function (Application $app, array $config) {
57+
$config["use_url_prefix"] = version_compare($app->version(), "9.33.0", "<");
5758
$client = $app->make(AliyunFactory::class)->createClient($config);
5859
$adapter = new AliyunAdapter($client, $config["bucket"], $config["prefix"] ?? "", $config);
5960
$driver = new Filesystem($adapter);

0 commit comments

Comments
 (0)