Skip to content

Commit b808652

Browse files
committed
[Fix] Handle special case for localhost in development environment in isThirdwebUrl function (#3369)
### TL;DR This PR updates the `isThirdwebUrl` function to properly handle the `localhost` hostname in the development environment. ### What changed? - Added a check to see if `process.env.NODE_ENV` is set to `development` - If in development, it checks if the hostname is `localhost` and treats it as a Thirdweb URL ### How to test? - Ensure the application runs in both development and production environments - In development, verify URLs with `localhost` return `true` for `isThirdwebUrl` - In production, verify URLs with `localhost` return `false` for `isThirdwebUrl` ### Why make this change? This change was made to correctly classify `localhost` as a Thirdweb URL when running in a development environment, allowing for better development workflow and environment parity. --- <!-- start pr-codex --> --- ## PR-Codex overview The focus of this PR is to exclude localhost from being considered a thirdweb URL, except in development mode. ### Detailed summary - Excludes localhost from thirdweb URL check in `fetch.ts` except in development mode. - Adds special handling for localhost in development environment. - Improves accuracy of identifying thirdweb URLs. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent c42a34f commit b808652

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

.changeset/brown-comics-unite.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
do not consider localhost a thirdweb url (except for dev mode)

packages/thirdweb/src/utils/fetch.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,18 @@ export function isThirdwebUrl(url: string): boolean {
9999
}
100100
try {
101101
const { hostname } = new URL(url);
102-
const is =
103-
THIRDWEB_DOMAINS.some((domain) => hostname.endsWith(domain)) ||
104-
hostname === "localhost";
102+
103+
try {
104+
// special case for localhost in development only
105+
if (process.env.NODE_ENV === "development") {
106+
if (hostname === "localhost") {
107+
IS_THIRDWEB_URL_CACHE.set(url, true);
108+
return true;
109+
}
110+
}
111+
} catch {}
112+
113+
const is = THIRDWEB_DOMAINS.some((domain) => hostname.endsWith(domain));
105114
IS_THIRDWEB_URL_CACHE.set(url, is);
106115
return is;
107116
} catch {

0 commit comments

Comments
 (0)