Skip to content

Commit 7bf10b0

Browse files
committed
fix(driver): bring endpoint and connection string to just a host
1 parent 77800f1 commit 7bf10b0

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

src/driver.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,9 @@ export default class Driver {
6969
'The "endpoint" and "database" fields are deprecated. Use "connectionString" instead',
7070
);
7171

72-
endpoint = settings.endpoint;
72+
secure = settings.endpoint.startsWith('grpcs://') || endpoint.startsWith('https://');
73+
endpoint = settings.endpoint.replace(/^(grpcs?|https?):\/\//, '');
7374
database = settings.database;
74-
75-
secure = endpoint.startsWith('grpcs://') || endpoint.startsWith('https://');
7675
}
7776

7877
if (settings.connectionString) {

src/utils/authenticated-service.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ type ServiceFactory<T> = {
1414
};
1515

1616
function removeProtocol(endpoint: string) {
17-
const re = /^(grpc:\/\/|grpcs:\/\/)?(.+)/;
18-
const match = re.exec(endpoint) as string[];
19-
return match[2];
17+
return endpoint.replace(/^(grpcs?|https?):\/\//, '');;
2018
}
2119

2220
export class StreamEnd extends Error {

0 commit comments

Comments
 (0)