Skip to content

Commit 2cec4b2

Browse files
authored
Update app/index.html for better deeplinking
1 parent f492371 commit 2cec4b2

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

app/index.html

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ <h1 class="title">Opening in <em>GitHub Store</em></h1>
475475
<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"/></svg>
476476
</div>
477477
<h1 class="title">Invalid Link</h1>
478-
<p class="subtitle" style="margin-bottom:24px;">This deep link doesn't point to a valid repository. Make sure the URL follows the format:<br><code style="font-size:0.8125rem;color:var(--md-primary);background:var(--md-surface-container-high);padding:4px 10px;border-radius:6px;display:inline-block;margin-top:8px;">github-store.org/app/{owner}/{repo}</code></p>
478+
<p class="subtitle" style="margin-bottom:24px;">This deep link doesn't point to a valid repository. Make sure the URL follows the format:<br><code style="font-size:0.8125rem;color:var(--md-primary);background:var(--md-surface-container-high);padding:4px 10px;border-radius:6px;display:inline-block;margin-top:8px;">github-store.org/app/?repo=owner/repo</code></p>
479479
<div class="actions">
480480
<a class="btn btn--filled" href="https://github-store.org">
481481
<svg viewBox="0 0 24 24" fill="currentColor"><path d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"/></svg>
@@ -495,39 +495,40 @@ <h1 class="title">Invalid Link</h1>
495495

496496
<script>
497497
(() => {
498-
// Parse /app/{owner}/{repo} from the URL path
499-
const path = window.location.pathname;
500-
const match = path.match(/^\/app\/([^/]+)\/([^/?#]+)/);
498+
const params = new URLSearchParams(window.location.search);
499+
const repo = params.get('repo');
501500

502501
const stateRedirecting = document.getElementById('stateRedirecting');
503502
const stateError = document.getElementById('stateError');
504503
const repoDisplay = document.getElementById('repoDisplay');
505504
const openAppBtn = document.getElementById('openAppBtn');
506505
const githubBtn = document.getElementById('githubBtn');
507506

508-
if (!match || !match[1] || !match[2]) {
509-
// Invalid URL — show error
507+
// Validate: must be "owner/repo" format
508+
const match = repo ? repo.match(/^([^/]+)\/([^/]+)$/) : null;
509+
510+
if (!match) {
510511
stateRedirecting.classList.remove('active');
511512
stateError.classList.add('active');
512513
return;
513514
}
514515

515-
const owner = decodeURIComponent(match[1]);
516-
const repo = decodeURIComponent(match[2]);
517-
const deepLink = `githubstore://repo/${owner}/${repo}`;
518-
const githubUrl = `https://github.com/${owner}/${repo}`;
516+
const owner = match[1];
517+
const repoName = match[2];
518+
const deepLink = `githubstore://repo/${owner}/${repoName}`;
519+
const githubUrl = `https://github.com/${owner}/${repoName}`;
519520

520521
// Set up UI
521-
repoDisplay.textContent = `${owner}/${repo}`;
522-
document.title = `Opening ${owner}/${repo} in GitHub Store`;
522+
repoDisplay.textContent = `${owner}/${repoName}`;
523+
document.title = `Opening ${owner}/${repoName} GitHub Store`;
523524
openAppBtn.href = deepLink;
524525
githubBtn.href = githubUrl;
525526

526-
// Attempt to open the app automatically after a short delay
527+
// Auto-redirect after a short delay
527528
setTimeout(() => {
528529
window.location.href = deepLink;
529530
}, 1500);
530531
})();
531532
</script>
532533
</body>
533-
</html>
534+
</html>

0 commit comments

Comments
 (0)