Skip to content

Commit 99bf109

Browse files
committed
Add clean /username URL format for sharing
1 parent b180862 commit 99bf109

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

public/_redirects

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* /index.html 200

src/components/GitSequencer.jsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ const GitSequencer = () => {
386386
ctx.fillStyle = colors.textDim;
387387
ctx.font = `${13 * scale}px monospace`;
388388
ctx.textAlign = 'center';
389-
ctx.fillText('gitmusic.niyasv.com', canvasWidth / 2, canvasHeight - 40 * scale);
389+
ctx.fillText(`gitmusic.niyasv.com`, canvasWidth / 2, canvasHeight - 40 * scale);
390390

391391
}, [data, activeCol, activeNotes, username]);
392392

@@ -473,7 +473,7 @@ const GitSequencer = () => {
473473

474474
// URL to clipboard
475475
const handleShare = () => {
476-
const shareUrl = `${window.location.origin}${window.location.pathname}?user=${encodeURIComponent(username)}`;
476+
const shareUrl = `${window.location.origin}/${encodeURIComponent(username)}`;
477477
navigator.clipboard.writeText(shareUrl).then(() => {
478478
setShowToast(true);
479479
}).catch(() => {
@@ -504,8 +504,13 @@ const GitSequencer = () => {
504504

505505
// Load user from URL on mount
506506
useEffect(() => {
507+
// Support both /username and ?user=username formats
508+
const pathname = window.location.pathname;
509+
const pathUser = pathname.split('/').filter(Boolean).pop();
507510
const params = new URLSearchParams(window.location.search);
508-
const userParam = params.get('user');
511+
const queryUser = params.get('user');
512+
513+
const userParam = pathUser || queryUser;
509514
if (userParam) {
510515
setUsername(userParam);
511516
loadData(userParam);

0 commit comments

Comments
 (0)