Skip to content

Commit 5512dd5

Browse files
committed
Handle invalid Sourcify API URL in useSourcifySupported hook
1 parent 48a647f commit 5512dd5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

apps/contract-verification/src/app/hooks/useSourcifySupported.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ export function useSourcifySupported(selectedChain: Chain, chainSettings: ChainS
1414
}
1515

1616
const queriedChainId = selectedChain.chainId
17-
const chainsUrl = new URL(sourcifyApi + '/chains')
17+
let chainsUrl: URL
18+
try {
19+
chainsUrl = new URL(sourcifyApi + '/chains')
20+
} catch (error) {
21+
console.error('Invalid Sourcify API URL:', sourcifyApi, error)
22+
return
23+
}
1824

1925
fetch(chainsUrl.href, { method: 'GET' })
2026
.then((response) => response.json())

0 commit comments

Comments
 (0)