Skip to content

Commit 9e5d7b9

Browse files
fix: scheme handling in set network (#3480)
Signed-off-by: venilinvasilev <[email protected]>
1 parent a72f5bb commit 9e5d7b9

File tree

3 files changed

+479
-103
lines changed

3 files changed

+479
-103
lines changed

src/channel/WebChannel.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,26 @@ export default class WebChannel extends Channel {
3939
// eslint-disable-next-line @typescript-eslint/no-misused-promises
4040
return async (method, requestData, callback) => {
4141
try {
42-
const shouldUseHttps = !(
43-
this._address.includes("localhost") ||
44-
this._address.includes("127.0.0.1")
45-
);
42+
// Check if address already contains a scheme
43+
const hasScheme =
44+
this._address.startsWith("http://") ||
45+
this._address.startsWith("https://");
46+
47+
let address;
48+
if (hasScheme) {
49+
// Use the address as-is if it already has a scheme
50+
address = this._address;
51+
} else {
52+
// Only prepend scheme if none exists
53+
const shouldUseHttps = !(
54+
this._address.includes("localhost") ||
55+
this._address.includes("127.0.0.1")
56+
);
4657

47-
const address = shouldUseHttps
48-
? `https://${this._address}`
49-
: `http://${this._address}`;
58+
address = shouldUseHttps
59+
? `https://${this._address}`
60+
: `http://${this._address}`;
61+
}
5062
// this will be executed in a browser environment so eslint is
5163
// disabled for the fetch call
5264
//eslint-disable-next-line n/no-unsupported-features/node-builtins

src/client/WebClient.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,19 @@ export default class WebClient extends Client {
249249
break;
250250
}
251251
} else {
252+
// Check for deprecation warnings for network endpoints with schemes
253+
for (const [key] of Object.entries(network)) {
254+
if (key.startsWith("https://") || key.startsWith("http://")) {
255+
console.warn(
256+
'[Deprecation Notice] Hiero SDK: Network endpoint "' +
257+
key +
258+
'" includes a URL scheme (e.g. "https://"). ' +
259+
"This format was accepted in earlier versions but is now deprecated. " +
260+
'Please remove the scheme and use "host:port" instead (e.g. "node00.swirldslabs.com:443"). ' +
261+
"Support for scheme-prefixed endpoints will be removed in a future major release.",
262+
);
263+
}
264+
}
252265
this._network.setNetwork(network);
253266
}
254267
}

0 commit comments

Comments
 (0)