Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Commit db21e7a

Browse files
committed
create a valid url from just hostname
1 parent 15c0a2b commit db21e7a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/configuration-manager/client.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,11 @@ async function createClient({
139139
dbPassword,
140140
onRequestFailed,
141141
}: CreateClientParams): Promise<MicrosoftConfigurationManagerClient> {
142+
if (!dbHost.startsWith('sql://')) {
143+
dbHost = `sql://${dbHost}`;
144+
}
142145
const url = new URL(dbHost);
143-
const server = url.host;
146+
const server = url.hostname;
144147
const port = url.port !== '' ? Number.parseInt(url.port, 10) : undefined;
145148
const pool = await sql.connect({
146149
server,

test/config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ if (process.env.LOAD_ENV) {
1111
});
1212
}
1313

14-
const DEFAULT_HOST = 'test_host';
14+
const DEFAULT_HOST = 'localhost';
1515
const DEFAULT_DATABASE = 'test_db';
1616
const DEFAULT_USERNAME = 'test_username';
1717
const DEFAULT_PASSWORD = 'fakepassword';

0 commit comments

Comments
 (0)