fix: handle invalid URL parsing in useFeedSafeUrl hook (#4823)
Wrap new URL() constructor in try-catch to gracefully handle malformed URL strings that start with 'http' but are invalid. Returns null instead of throwing. Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
d58720aae6
commit
62efdd29b2
|
|
@ -31,8 +31,12 @@ export const useFeedSafeUrl = (entryId: string) => {
|
|||
}
|
||||
|
||||
if (href.startsWith("http")) {
|
||||
const domain = new URL(href).hostname
|
||||
if (domain === "localhost") return null
|
||||
try {
|
||||
const domain = new URL(href).hostname
|
||||
if (domain === "localhost") return null
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
|
||||
return href
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue