mirror of
https://github.com/dergigi/boris.git
synced 2025-12-17 22:54:30 +01:00
fix: resolve TypeScript errors in nostrUriResolver.tsx
- Add explicit type annotations for decoded variable and npub parameter - Use switch statement for better type narrowing when checking npub type
This commit is contained in:
@@ -378,14 +378,12 @@ export function addLoadingClassToProfileLinks(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find all <a> tags with href starting with /p/ (profile links)
|
// Find all <a> tags with href starting with /p/ (profile links)
|
||||||
const result = html.replace(/<a\s+[^>]*?href="\/p\/([^"]+)"[^>]*?>/g, (match, npub) => {
|
const result = html.replace(/<a\s+[^>]*?href="\/p\/([^"]+)"[^>]*?>/g, (match, npub: string) => {
|
||||||
try {
|
try {
|
||||||
// Decode npub to get pubkey
|
// Decode npub to get pubkey
|
||||||
const decoded = decode(npub)
|
const decoded: ReturnType<typeof decode> = decode(npub)
|
||||||
if (decoded.type !== 'npub') {
|
switch (decoded.type) {
|
||||||
return match
|
case 'npub': {
|
||||||
}
|
|
||||||
|
|
||||||
const pubkey = decoded.data
|
const pubkey = decoded.data
|
||||||
|
|
||||||
// Check if this profile is loading
|
// Check if this profile is loading
|
||||||
@@ -405,6 +403,12 @@ export function addLoadingClassToProfileLinks(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
// Not an npub, ignore
|
||||||
|
break
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Ignore processing errors
|
// Ignore processing errors
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user