Improved attachment name generation from DTO url

We dont include the query paramaters in the name anymore
This commit is contained in:
Jan Böhmer 2023-07-29 18:38:18 +02:00
parent 11be65678e
commit 1c222ff293

View file

@ -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