create-prisma-php-app 1.20.3 → 1.20.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -296,29 +296,33 @@ class UploadFile
296
296
 
297
297
  protected function checkName(array $file): void
298
298
  {
299
- $name = str_replace(' ', '_', $file['name']);
300
- $nameParts = pathinfo($name);
299
+ $this->newName = '';
300
+ $noSpaces = str_replace(' ', '_', $file['name']);
301
+ if ($noSpaces != $file['name']) {
302
+ $this->newName = $noSpaces;
303
+ }
304
+ $nameParts = pathinfo($noSpaces);
301
305
  $extension = $nameParts['extension'] ?? '';
302
-
303
- // Handle trusted vs untrusted extensions
304
- if (!$this->typeCheckingOn && (in_array($extension, $this->notTrusted) || empty($extension))) {
305
- $this->newName = $name . $this->suffix;
306
+ if (!$this->typeCheckingOn && !empty($this->suffix)) {
307
+ if (in_array($extension, $this->notTrusted) || empty($extension)) {
308
+ $this->newName = $noSpaces . $this->suffix;
309
+ }
306
310
  }
307
-
308
- // Rename duplicates if necessary
309
311
  if ($this->renameDuplicates) {
310
- $existingFiles = scandir($this->destination);
311
- $originalName = $name;
312
- $i = 1;
313
-
314
- while (in_array($name, $existingFiles)) {
315
- $name = "{$nameParts['filename']}_$i." . ($extension ?: ''); // Maintain the extension if available
316
- $i++;
312
+ $name = isset($this->newName) ? $this->newName : $file['name'];
313
+ $existing = scandir($this->destination);
314
+ if (in_array($name, $existing)) {
315
+ $i = 1;
316
+ do {
317
+ $this->newName = $nameParts['filename'] . '_' . $i++;
318
+ if (!empty($extension)) {
319
+ $this->newName .= ".$extension";
320
+ }
321
+ if (in_array($extension, $this->notTrusted)) {
322
+ $this->newName .= $this->suffix;
323
+ }
324
+ } while (in_array($this->newName, $existing));
317
325
  }
318
-
319
- $this->newName = $name;
320
- } else {
321
- $this->newName = $name;
322
326
  }
323
327
  }
324
328
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma-php-app",
3
- "version": "1.20.3",
3
+ "version": "1.20.4",
4
4
  "description": "Prisma-PHP: A Revolutionary Library Bridging PHP with Prisma ORM",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",