mirror of
https://github.com/PR0M3TH3AN/NostrTipJar.git
synced 2025-09-09 07:49:19 +00:00
update
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Nostr Tip Jar</title>
|
<title>Lightning Tip Jar</title>
|
||||||
|
|
||||||
<!-- TailwindCSS (Play CDN for demo) -->
|
<!-- TailwindCSS (Play CDN for demo) -->
|
||||||
<script src="https://cdn.tailwindcss.com"></script>
|
<script src="https://cdn.tailwindcss.com"></script>
|
||||||
@@ -59,12 +59,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function parseUrl() {
|
function parseUrl() {
|
||||||
const parts = location.pathname.split("/").filter(Boolean);
|
// Always use query parameter 'n' for npub
|
||||||
let npub = null;
|
const params = new URLSearchParams(window.location.search);
|
||||||
if (parts[0] === "n" && parts[1]) npub = parts[1];
|
const npub = params.get("n");
|
||||||
else npub = new URLSearchParams(location.search).get("n");
|
// Base is the URL of the HTML file (strip query and hash)
|
||||||
const idx = location.pathname.indexOf("/n/");
|
const base = window.location.href.split('?')[0].split('#')[0];
|
||||||
const base = idx > 0 ? location.pathname.slice(0, idx) : location.pathname;
|
|
||||||
return { npub, base };
|
return { npub, base };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,9 +82,10 @@
|
|||||||
document.getElementById('form').onsubmit = e => {
|
document.getElementById('form').onsubmit = e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const v = document.getElementById('input').value.trim();
|
const v = document.getElementById('input').value.trim();
|
||||||
if (!v.startsWith('npub')) return renderLanding(base, 'npub must start with "npub".');
|
if (!v.startsWith('npub')) { renderLanding(base, 'npub must start with "npub".'); return; }
|
||||||
const isFile = /\.html?$/.test(base);
|
const baseUrl = window.location.href.split('?')[0].split('#')[0];
|
||||||
location.href = isFile ? `${base}?n=${v}` : `${base.replace(/\/$/, '')}/n/${v}`;
|
log('Redirecting to', `${baseUrl}?n=${v}`);
|
||||||
|
location.href = `${baseUrl}?n=${v}`;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user