Skip to content

Commit

Permalink
Merge pull request #1506 from craftcms/bugfix/1489-matching-asset-by-…
Browse files Browse the repository at this point in the history
…filename

if we don't have extension, don't add a full stop to the filename
  • Loading branch information
angrybrad authored Sep 25, 2024
2 parents e28b876 + 49a35a4 commit e908d60
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/fields/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,14 @@ public function parseField(): mixed
$urlsToUpload[$key]['value'] = $dataValue;

if (isset($filenamesFromFeed[$key])) {
$filename = $filenamesFromFeed[$key] . '.' . AssetHelper::getRemoteUrlExtension($urlsToUpload[$key]['value']);
$filename = $filenamesFromFeed[$key];

// if we can determine the extension of the remote file, use that extension
$remoteUrlExtension = AssetHelper::getRemoteUrlExtension($urlsToUpload[$key]['value']);
if (!empty($remoteUrlExtension)) {
$filename .= '.' . $remoteUrlExtension;
}

$urlsToUpload[$key]['newFilename'] = $filename;
} else {
$filename = AssetHelper::getRemoteUrlFilename($dataValue);
Expand Down

0 comments on commit e908d60

Please sign in to comment.