diff --git a/e2e/tests/game.spec.js b/e2e/tests/game.spec.js index e7d4957..459a357 100644 --- a/e2e/tests/game.spec.js +++ b/e2e/tests/game.spec.js @@ -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([]); diff --git a/frontend/src/utils/shareCard.js b/frontend/src/utils/shareCard.js index 36ce8dc..f7a5257 100644 --- a/frontend/src/utils/shareCard.js +++ b/frontend/src/utils/shareCard.js @@ -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') {