Skip to content

Commit

Permalink
Merge pull request #202 from ArmaForces/feature/restore_old_filename
Browse files Browse the repository at this point in the history
Restore old filename of downloaded modlist
  • Loading branch information
veteran29 authored Apr 12, 2021
2 parents 8baa906 + 369a25e commit 92e7bda
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/Controller/ModListPublicController.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function customizeAction(ModList $modList): Response
*/
public function downloadAction(ModList $modList, string $optionalModsJson = null): Response
{
$name = sprintf('AF %s %s.html', $modList->getName(), (new \DateTimeImmutable())->format('Y-m-d H-i-s'));
$name = sprintf('ArmaForces %s %s', $modList->getName(), (new \DateTimeImmutable())->format('Y_m_d H_i'));
$mods = $this->modRepository->findIncludedSteamWorkshopMods($modList);
$optionalMods = json_decode($optionalModsJson ?? '', true) ?: [];

Expand All @@ -79,7 +79,10 @@ public function downloadAction(ModList $modList, string $optionalModsJson = null
]);

return new Response($template, Response::HTTP_OK, [
'Content-Disposition' => HeaderUtils::makeDisposition(HeaderUtils::DISPOSITION_ATTACHMENT, $name),
'Content-Disposition' => HeaderUtils::makeDisposition(
HeaderUtils::DISPOSITION_ATTACHMENT,
$name.'.html'
),
]);
}
}
2 changes: 1 addition & 1 deletion src/Test/Traits/AssertsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static function assertTeamSpeakUrlVisible(Crawler $crawler, bool $visible
public static function assertResponseContainsModListAttachmentHeader(Response $response, ModList $modList): void
{
$contentDispositionHeader = $response->headers->get('Content-Disposition');
$pattern = "/^attachment; filename=\"AF {$modList->getName()} \\d{4}-\\d{2}-\\d{2} \\d{2}-\\d{2}-\\d{2}.html\"$/";
$pattern = "/^attachment; filename=\"ArmaForces {$modList->getName()} \\d{4}_\\d{2}_\\d{2} \\d{2}_\\d{2}.html\"$/";

self::assertTrue(1 === preg_match($pattern, $contentDispositionHeader));
}
Expand Down

0 comments on commit 92e7bda

Please sign in to comment.