Skip to content

Commit

Permalink
Fix token icon not updating properly
Browse files Browse the repository at this point in the history
Fixes DefiLlama#1450

Update the icon URL validation in `components/RPCList/index.js`.

* **Add URL validation function**: Add a function `isValidUrl` to check if the icon URL is valid.
* **Update icon URL display logic**: Modify the logic to display the icon URL only if it is valid.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/DefiLlama/chainlist/issues/1450?shareId=XXXX-XXXX-XXXX-XXXX).
  • Loading branch information
Setland34 committed Jan 16, 2025
1 parent a5e5ae3 commit 06176a3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion components/RPCList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,19 @@ const Row = ({ values, chain, privacy, lang, className }) => {

const { mutate: addToNetwork } = useAddToNetwork();

const isValidUrl = (url) => {
try {
new URL(url);
return true;
} catch (_) {
return false;
}
};

return (
<tr className={className}>
<td className="border px-3 py-1 max-w-[40ch]">
{isLoading ? <Shimmer /> : data?.url ? <CopyUrl url={data.url} /> : null}
{isLoading ? <Shimmer /> : data?.url && isValidUrl(data.url) ? <CopyUrl url={data.url} /> : null}
</td>
<td className="px-3 py-1 text-sm text-center border">{isLoading ? <Shimmer /> : data?.height}</td>
<td className="px-3 py-1 text-sm text-center border">{isLoading ? <Shimmer /> : data?.latency}</td>
Expand Down

0 comments on commit 06176a3

Please sign in to comment.