mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-08 17:34:32 +02:00
Improved attachment name generation from DTO url
We dont include the query paramaters in the name anymore
This commit is contained in:
parent
11be65678e
commit
1c222ff293
1 changed files with 6 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue