From 1c222ff2932a95be319b519e3dc1cd60d8157235 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sat, 29 Jul 2023 18:38:18 +0200 Subject: [PATCH] Improved attachment name generation from DTO url We dont include the query paramaters in the name anymore --- src/Services/InfoProviderSystem/DTOtoEntityConverter.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Services/InfoProviderSystem/DTOtoEntityConverter.php b/src/Services/InfoProviderSystem/DTOtoEntityConverter.php index 4a359a03..a7f5551e 100644 --- a/src/Services/InfoProviderSystem/DTOtoEntityConverter.php +++ b/src/Services/InfoProviderSystem/DTOtoEntityConverter.php @@ -130,7 +130,7 @@ final class DTOtoEntityConverter //If no name is given, try to extract the name from the URL if (empty($dto->name)) { - $entity->setName(basename($dto->url)); + $entity->setName($this->getAttachmentNameFromURL($dto->url)); } else { $entity->setName($dto->name); } @@ -138,6 +138,11 @@ final class DTOtoEntityConverter return $entity; } + private function getAttachmentNameFromURL(string $url): string + { + return basename(parse_url($url, PHP_URL_PATH)); + } + /** * Converts a PartDetailDTO to a Part entity * @param PartDetailDTO $dto