Skip to content

Commit b0a8d72

Browse files
committed
Simplify invite flow
1 parent 8f960d1 commit b0a8d72

3 files changed

Lines changed: 11 additions & 108 deletions

File tree

404.html

Lines changed: 9 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -3,89 +3,23 @@
33
<head>
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<title>Retune Invite</title>
7-
8-
<!-- Open Graph meta tags for invite links - important for social media previews -->
9-
<meta property="og:title" content="Join me on Retune" />
10-
<meta property="og:description" content="Discover new music and explore what people are listening to around you." />
11-
<meta property="og:image" content="https://raw.githubusercontent.com/ucladevx/retune-website/2025-update/assets/images/retune_icon.png" />
12-
<meta property="og:url" content="https://retuneapp.com/invite" />
13-
<meta property="og:type" content="website" />
14-
15-
<!-- Universal Links / App Links -->
16-
<link rel="apple-app-site-association" href="/.well-known/apple-app-site-association">
17-
<meta name="apple-itunes-app" content="app-id=6741438431">
18-
6+
<title>Page Not Found - Retune</title>
197
<script>
20-
// Immediate redirect - execute immediately
8+
// Don't interfere with .well-known files
219
(function() {
2210
var path = window.location.pathname;
23-
24-
// Don't interfere with .well-known files
2511
if (path.indexOf('/.well-known/') === 0) {
26-
return;
27-
}
28-
29-
// Handle /invite/{code} - redirect to query parameter format
30-
var inviteMatch = path.match(/\/invite\/([^\/]+)/);
31-
if (inviteMatch && inviteMatch[1]) {
32-
var code = encodeURIComponent(inviteMatch[1]);
33-
window.location.replace('/invite?code=' + code);
34-
return;
35-
}
36-
37-
// Handle /invite (without code in path) - load invite page directly
38-
if (path === '/invite' || path === '/invite/') {
39-
// If we're here, GitHub Pages isn't serving /invite/index.html correctly
40-
// Load the invite page content directly
41-
fetch('/invite/index.html')
42-
.then(function(response) {
43-
if (!response.ok) throw new Error('Failed to load');
44-
return response.text();
45-
})
46-
.then(function(html) {
47-
var parser = new DOMParser();
48-
var doc = parser.parseFromString(html, 'text/html');
49-
50-
// Replace head content
51-
Array.from(doc.head.children).forEach(function(child) {
52-
if (child.tagName !== 'TITLE') {
53-
document.head.appendChild(child.cloneNode(true));
54-
}
55-
});
56-
57-
// Replace body content
58-
document.body.innerHTML = doc.body.innerHTML;
59-
60-
// Execute scripts
61-
var scripts = doc.querySelectorAll('script');
62-
scripts.forEach(function(oldScript) {
63-
var newScript = document.createElement('script');
64-
if (oldScript.src) {
65-
newScript.src = oldScript.src;
66-
} else {
67-
newScript.textContent = oldScript.textContent;
68-
}
69-
document.body.appendChild(newScript);
70-
});
71-
})
72-
.catch(function() {
73-
// Fallback: try redirecting with trailing slash
74-
if (path === '/invite') {
75-
window.location.replace('/invite/' + window.location.search);
76-
}
77-
});
78-
return;
12+
return; // Let GitHub Pages serve the file
7913
}
80-
81-
// For other 404s, redirect to home
82-
window.location.replace('/');
14+
// Everything else is a 404 - show page not found
8315
})();
8416
</script>
8517
</head>
86-
<body>
87-
<div style="display:flex; justify-content:center; align-items:center; height:100vh; font-family:sans-serif; text-align:center;">
88-
<p>Redirecting...</p>
18+
<body style="display:flex; justify-content:center; align-items:center; height:100vh; font-family:sans-serif; text-align:center;">
19+
<div>
20+
<h1>404 - Page Not Found</h1>
21+
<p>The page you're looking for doesn't exist.</p>
22+
<p><a href="/" style="color: #ff6600;">Return to home</a></p>
8923
</div>
9024
</body>
9125
</html>

invite.html

Lines changed: 0 additions & 23 deletions
This file was deleted.

invite/index.html

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,10 @@ <h1>You're invited to Retune!</h1>
2525
</div>
2626

2727
<script>
28-
// Extract invite code from URL path or query parameter
29-
const path = window.location.pathname;
28+
// Extract invite code from query parameter only
3029
const searchParams = new URLSearchParams(window.location.search);
31-
const pathMatch = path.match(/\/invite\/([^\/]+)/);
32-
const inviteCode = pathMatch && pathMatch[1] ? pathMatch[1] : searchParams.get('code');
30+
const inviteCode = searchParams.get('code');
3331

34-
// Update og:url to match the actual URL (important for social media previews)
35-
const ogUrl = document.getElementById('og-url');
36-
if (ogUrl) {
37-
// Set og:url to the current full URL
38-
ogUrl.setAttribute('content', window.location.href.split('#')[0]); // Remove hash if present
39-
}
4032
const message = document.getElementById("message");
4133
const content = document.getElementById("content");
4234

0 commit comments

Comments
 (0)