Browse Source

remove nip33 and replace with naddr

master
Silberengel 10 months ago
parent
commit
1522fa17ce
  1. 10
      src/lib/components/util/CardActions.svelte
  2. 8
      src/routes/events/+page.svelte

10
src/lib/components/util/CardActions.svelte

@ -82,19 +82,19 @@
detailsModalOpen = true; detailsModalOpen = true;
} }
// --- Custom JSON pretty-printer with NIP-33 address hyperlinking --- // --- Custom JSON pretty-printer with naddr hyperlinking ---
/** /**
* Returns HTML for pretty-printed JSON, with NIP-33 addresses as links to /events?id=naddr1... * Returns HTML for pretty-printed JSON, with naddrs as links to /events?id=naddr1...
*/ */
function jsonWithNaddrLinks(obj: any): string { function jsonWithNaddrLinks(obj: any): string {
const NIP33_REGEX = /\b(\d{5}:[a-f0-9]{64}:[a-zA-Z0-9._-]+)\b/g; const NADDR_REGEX = /\b(\d{5}:[a-f0-9]{64}:[a-zA-Z0-9._-]+)\b/g;
function replacer(_key: string, value: any) { function replacer(_key: string, value: any) {
return value; return value;
} }
// Stringify with 2-space indent // Stringify with 2-space indent
let json = JSON.stringify(obj, replacer, 2); let json = JSON.stringify(obj, replacer, 2);
// Replace NIP-33 addresses with links // Replace naddr addresses with links
json = json.replace(NIP33_REGEX, (match) => { json = json.replace(NADDR_REGEX, (match) => {
try { try {
const [kind, pubkey, dtag] = match.split(":"); const [kind, pubkey, dtag] = match.split(":");
// Compose a fake event for naddrEncode // Compose a fake event for naddrEncode

8
src/routes/events/+page.svelte

@ -127,10 +127,10 @@
} }
/** /**
* Returns HTML for pretty-printed JSON, with NIP-33 addresses and event IDs as links * Returns HTML for pretty-printed JSON, with naddr addresses and event IDs as links
*/ */
function jsonWithLinks(obj: any): string { function jsonWithLinks(obj: any): string {
const NIP33_REGEX = /\b(\d{5}:[a-f0-9]{64}:[a-zA-Z0-9._-]+)\b/g; const NADDR_REGEX = /\b(\d{5}:[a-f0-9]{64}:[a-zA-Z0-9._-]+)\b/g;
const EVENT_ID_REGEX = /\b([0-9a-f]{64})\b/g; const EVENT_ID_REGEX = /\b([0-9a-f]{64})\b/g;
function replacer(_key: string, value: any) { function replacer(_key: string, value: any) {
@ -139,8 +139,8 @@
// Stringify with 2-space indent // Stringify with 2-space indent
let json = JSON.stringify(obj, replacer, 2); let json = JSON.stringify(obj, replacer, 2);
// Replace NIP-33 addresses with links // Replace addresses with links
json = json.replace(NIP33_REGEX, (match) => { json = json.replace(NADDR_REGEX, (match) => {
try { try {
const [kind, pubkey, dtag] = match.split(":"); const [kind, pubkey, dtag] = match.split(":");
// Compose a fake event for naddrEncode // Compose a fake event for naddrEncode

Loading…
Cancel
Save