Skip to content

Commit

Permalink
Merge branch '5.x' into 6.x
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
  • Loading branch information
angrybrad committed Sep 25, 2024
2 parents 964eea3 + 51707c1 commit ff1844b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes for Feed Me

## Unreleased

- Fixed a bug that could occur when uploading files to an Assets field from an external URL and a new filename is provided, but we can't determine the remote file's extension. ([#1506](https://github.com/craftcms/feed-me/pull/1506))

## 6.3.0 - 2024-08-14

- Added a `feed-me/logs/clear` console command to clear database logs.
Expand Down
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 ff1844b

Please sign in to comment.