Skip to content

Conversation

Ovgodd
Copy link
Collaborator

@Ovgodd Ovgodd commented Oct 2, 2025

Purpose

Fix the filename used when downloading an attachment. Previously, the file was downloaded with its UUID, which was not user-friendly.

issue : 1413

Capture d'écran 2025-10-02 112126

Proposal

  • Use the document title (fileBlock.props.name) as the primary filename
  • Fallback to the last segment of the URL if no title is provided
  • Default to "file" if neither is available

@Ovgodd Ovgodd self-assigned this Oct 2, 2025
@Ovgodd Ovgodd force-pushed the fix/1413-correct-download-attachments-name branch from 616011c to 736c76a Compare October 2, 2025 09:34
Copy link

github-actions bot commented Oct 2, 2025

Size Change: +52 B (0%)

Total Size: 3.66 MB

Filename Size Change
apps/impress/out/_next/static/1906d41b/_buildManifest.js 0 B -863 B (removed) 🏆
apps/impress/out/_next/static/8ff2d068/_buildManifest.js 864 B +864 B (new file) 🆕

compressed-size-action

@Ovgodd Ovgodd force-pushed the fix/1413-correct-download-attachments-name branch from 736c76a to 483730e Compare October 2, 2025 11:12
@Ovgodd Ovgodd requested a review from AntoLC October 2, 2025 11:12
@Ovgodd Ovgodd marked this pull request as ready for review October 2, 2025 11:12
@Ovgodd Ovgodd force-pushed the fix/1413-correct-download-attachments-name branch 5 times, most recently from aa5294a to bb41aa1 Compare October 2, 2025 14:08
@AntoLC AntoLC linked an issue Oct 3, 2025 that may be closed by this pull request
@AntoLC AntoLC linked an issue Oct 3, 2025 that may be closed by this pull request
Copy link
Collaborator

@AntoLC AntoLC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, works perfectly !
2 small comments.

I took the freedom to improve a bit our linter in this PR, it will highlight some fix that you will have to do, there are auto fixable.

Comment on lines 90 to 93
const unsafeName = baseName.includes('.')
? baseName.replace(/(\.[^/.]+)$/, '-unsafe$1')
: baseName + '-unsafe';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const unsafeName = baseName.includes('.')
? baseName.replace(/(\.[^/.]+)$/, '-unsafe$1')
: baseName + '-unsafe';
const regFindLastDot = /(\.[^/.]+)$/;
const unsafeName = baseName.includes('.')
? baseName.replace(regFindLastDot, '-unsafe$1')
: baseName + '-unsafe';

Comment on lines 904 to 877
await page.locator('.bn-block-content[data-content-type="pdf"]').click();

await page.locator('[data-test="downloadfile"]').click();

const download = await downloadPromise;
expect(download.suggestedFilename()).toBe('test-pdf.pdf');
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not necessary to create a new test, could you maybe add this part in the test above (it embeds PDF) ?

@Ovgodd
Copy link
Collaborator Author

Ovgodd commented Oct 6, 2025

Nice, works perfectly ! 2 small comments.

I took the freedom to improve a bit our linter in this PR, it will highlight some fix that you will have to do, there are auto fixable.

Oh that's great 👍 !

@Ovgodd Ovgodd force-pushed the fix/1413-correct-download-attachments-name branch from c22b84b to 3e32128 Compare October 6, 2025 08:42
@Ovgodd Ovgodd requested a review from AntoLC October 6, 2025 09:18
@Ovgodd Ovgodd force-pushed the fix/1413-correct-download-attachments-name branch 2 times, most recently from 0f90312 to 504109a Compare October 6, 2025 09:38
@Ovgodd Ovgodd force-pushed the fix/1413-correct-download-attachments-name branch from 504109a to cf3d526 Compare October 6, 2025 14:38
Ovgodd and others added 2 commits October 6, 2025 16:49
use the document title instead of the uuid when downloading attachments

Signed-off-by: Cyril <c.gromoff@gmail.com>
Add no-unnecessary-type-assertion rule to eslint
config to avoid automatically unnecessary type
assertions in the codebase.
@Ovgodd Ovgodd force-pushed the fix/1413-correct-download-attachments-name branch from cf3d526 to 236c8df Compare October 6, 2025 14:50
@Ovgodd Ovgodd merged commit 236c8df into main Oct 6, 2025
21 of 22 checks passed
@Ovgodd Ovgodd deleted the fix/1413-correct-download-attachments-name branch October 6, 2025 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 Download attachments with uuid
2 participants