Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions e2e/tests/game.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ test('win on a file-share-capable device hands the card to the native share shee
const shared = await a.evaluate(() => window.__shared);
expect(shared.files).toHaveLength(1);
expect(shared.files[0].type).toBe('image/png');
expect(shared.text).toContain('http');

const opened = await a.evaluate(() => window.__opened);
expect(opened).toEqual([]);
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/utils/shareCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,11 @@ export const shareCardImage = async (blob, { text, url, fallback = 'download' })
const file = new File([blob], 'tic-tac-two-victory.png', { type: 'image/png' });
if (navigator.canShare && navigator.canShare({ files: [file] })) {
try {
await navigator.share({ files: [file], text, url });
// On Android, share targets receiving files only reliably read `text`;
// the separate `url` member gets dropped, so fold the url into text
// while still passing `url` for platforms that do honor it
const shareText = text && url ? `${text} ${url}` : text;
await navigator.share({ files: [file], text: shareText, url });
return 'shared';
} catch (err) {
if (err && err.name === 'AbortError') {
Expand Down
Loading