Handle npub inputs in goToProfile

This commit is contained in:
thePR0M3TH3AN committed 2026-01-14 20:28:12 -05:00
1 parent a5ec2fb54f
commit 5c2d7133e6
1 file changed
+25 -8
+25 -8
View File
@@ -719,18 +719,35 @@ class Application {
}
goToProfile(pubkey) {
if (!pubkey) {
if (typeof pubkey !== "string") {
this.showError("No creator info available.");
return;
}
try {
const npub = window.NostrTools.nip19.npubEncode(pubkey);
// Switch to channel profile view
window.location.hash = `#view=channel-profile&npub=${npub}`;
} catch (err) {
devLogger.error("Failed to go to channel:", err);
this.showError("Could not open channel.");
const trimmed = pubkey.trim();
if (!trimmed) {
this.showError("No creator info available.");
return;
}
let npub = null;
if (trimmed.startsWith("npub1")) {
const decoded = this.safeDecodeNpub(trimmed);
if (decoded && HEX64_REGEX.test(decoded)) {
npub = this.safeEncodeNpub(decoded);
}
} else if (HEX64_REGEX.test(trimmed)) {
npub = this.safeEncodeNpub(trimmed);
}
if (!npub) {
devLogger.warn("[Application] Invalid pubkey for profile navigation:", trimmed);
this.showError("Invalid creator profile.");
return;
}
window.location.hash = `#view=channel-profile&npub=${npub}`;
}
openCreatorChannel() {