Save workspace changes
This commit is contained in:
@@ -11,6 +11,7 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Str;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
|
||||
final class ArtworkDownloadController extends Controller
|
||||
@@ -155,10 +156,31 @@ final class ArtworkDownloadController extends Controller
|
||||
$name = 'artwork';
|
||||
}
|
||||
|
||||
if (strtolower((string) pathinfo($name, PATHINFO_EXTENSION)) !== $ext) {
|
||||
$name .= '.' . $ext;
|
||||
$baseName = pathinfo($name, PATHINFO_FILENAME);
|
||||
$baseName = trim((string) $baseName, ". \t\n\r\0\x0B");
|
||||
if ($baseName === '') {
|
||||
$baseName = 'artwork';
|
||||
}
|
||||
|
||||
return $name;
|
||||
$brandSuffix = $this->downloadBrandSuffix();
|
||||
|
||||
if ($brandSuffix !== '' && ! Str::contains(Str::lower($baseName), Str::lower($brandSuffix))) {
|
||||
$baseName .= ' (' . $brandSuffix . ')';
|
||||
}
|
||||
|
||||
return $baseName . '.' . $ext;
|
||||
}
|
||||
|
||||
private function downloadBrandSuffix(): string
|
||||
{
|
||||
$host = (string) parse_url((string) config('app.url'), PHP_URL_HOST);
|
||||
$host = strtolower(trim($host));
|
||||
$host = preg_replace('/^www\./', '', $host) ?? '';
|
||||
|
||||
if ($host === '' || in_array($host, ['localhost', '127.0.0.1'], true) || str_ends_with($host, '.test')) {
|
||||
return 'skinbase.top';
|
||||
}
|
||||
|
||||
return $host;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user