File tree 2 files changed +27
-1
lines changed
main/java/net/snowflake/client/core
test/java/net/snowflake/client/core
2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -426,7 +426,11 @@ static boolean getBooleanValue(Object v) {
426
426
String getHostFromServerUrl () throws SFException {
427
427
URL url ;
428
428
try {
429
- url = new URL (serverUrl );
429
+ if (!serverUrl .startsWith ("http" )) {
430
+ url = new URL ("https://" + serverUrl );
431
+ } else {
432
+ url = new URL (serverUrl );
433
+ }
430
434
} catch (MalformedURLException e ) {
431
435
throw new SFException (
432
436
e , ErrorCode .INTERNAL_ERROR , "Invalid serverUrl for retrieving host name" );
Original file line number Diff line number Diff line change
1
+ package net .snowflake .client .core ;
2
+
3
+ import static org .junit .Assert .assertEquals ;
4
+
5
+ import org .junit .Test ;
6
+
7
+ public class SFLoginInputTest {
8
+
9
+ @ Test
10
+ public void testGetHostFromServerUrlWithoutProtocolShouldNotThrow () throws SFException {
11
+ SFLoginInput sfLoginInput = new SFLoginInput ();
12
+ sfLoginInput .setServerUrl ("host.com:443" );
13
+ assertEquals ("host.com" , sfLoginInput .getHostFromServerUrl ());
14
+ }
15
+
16
+ @ Test
17
+ public void testGetHostFromServerUrlWithProtocolShouldNotThrow () throws SFException {
18
+ SFLoginInput sfLoginInput = new SFLoginInput ();
19
+ sfLoginInput .setServerUrl ("https://host.com" );
20
+ assertEquals ("host.com" , sfLoginInput .getHostFromServerUrl ());
21
+ }
22
+ }
You can’t perform that action at this time.
0 commit comments