Skip to content

Commit 6e52d93

Browse files
VSCODE-198: Use RFC 3986 encoding (#207)
* fix: Use RFC 3986 encoding (VSCODE-198) * fix: do not store driverUrl in keychain * fix: use driverUrlWithSsh when copying connection string
1 parent c82c22a commit 6e52d93

File tree

7 files changed

+99
-98
lines changed

7 files changed

+99
-98
lines changed

package-lock.json

Lines changed: 32 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -832,8 +832,8 @@
832832
"encoding": "^0.1.12",
833833
"micromatch": "^4.0.2",
834834
"mongodb-cloud-info": "^1.1.2",
835-
"mongodb-connection-model": "^17.0.2",
836-
"mongodb-data-service": "^16.8.1",
835+
"mongodb-connection-model": "^17.0.3",
836+
"mongodb-data-service": "^17.0.3",
837837
"mongodb-ns": "^2.2.0",
838838
"mongodb-schema": "^8.2.5",
839839
"numeral": "^2.0.6",

src/connectionController.ts

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const MAX_CONNECTION_NAME_LENGTH = 512;
2020

2121
export enum DataServiceEventTypes {
2222
CONNECTIONS_DID_CHANGE = 'CONNECTIONS_DID_CHANGE',
23-
ACTIVE_CONNECTION_CHANGED = 'ACTIVE_CONNECTION_CHANGED',
23+
ACTIVE_CONNECTION_CHANGED = 'ACTIVE_CONNECTION_CHANGED'
2424
}
2525

2626
export enum ConnectionTypes {
@@ -31,7 +31,6 @@ export enum ConnectionTypes {
3131

3232
export type SavedConnectionInformation = {
3333
connectionModel: ConnectionModelType;
34-
driverUrl: string;
3534
};
3635

3736
// A loaded connection contains connection information.
@@ -114,7 +113,6 @@ export default class ConnectionController {
114113

115114
loadedSavedConnection = {
116115
id: connectionId,
117-
driverUrl: connectionInformation.driverUrl,
118116
name: savedConnection.name,
119117
connectionModel: connectionInformation.connectionModel,
120118
storageLocation: savedConnection.storageLocation
@@ -125,7 +123,10 @@ export default class ConnectionController {
125123
return Promise.resolve();
126124
}
127125

128-
this._connections[connectionId] = loadedSavedConnection;
126+
this._connections[connectionId] = {
127+
...loadedSavedConnection,
128+
connectionModel: new Connection(loadedSavedConnection.connectionModel)
129+
};
129130
this.eventEmitter.emit(DataServiceEventTypes.CONNECTIONS_DID_CHANGE);
130131

131132
Promise.resolve();
@@ -271,8 +272,7 @@ export default class ConnectionController {
271272
});
272273
const connectionId = uuidv4();
273274
const connectionInformation: SavedConnectionInformation = {
274-
connectionModel,
275-
driverUrl
275+
connectionModel
276276
};
277277
const connectionName =
278278
sshTunnelOptions.host && sshTunnelOptions.port
@@ -551,13 +551,13 @@ export default class ConnectionController {
551551
const connectionNameToRemove:
552552
| string
553553
| undefined = await vscode.window.showQuickPick(
554-
connectionIds.map(
555-
(id, index) => `${index + 1}: ${this._connections[id].name}`
556-
),
557-
{
558-
placeHolder: 'Choose a connection to remove...'
559-
}
560-
);
554+
connectionIds.map(
555+
(id, index) => `${index + 1}: ${this._connections[id].name}`
556+
),
557+
{
558+
placeHolder: 'Choose a connection to remove...'
559+
}
560+
);
561561

562562
if (!connectionNameToRemove) {
563563
return Promise.resolve(false);
@@ -641,7 +641,8 @@ export default class ConnectionController {
641641
return null;
642642
}
643643

644-
return this._connections[this._currentConnectionId].driverUrl;
644+
return this._connections[this._currentConnectionId].connectionModel
645+
.driverUrl;
645646
}
646647

647648
public addEventListener(
@@ -694,7 +695,7 @@ export default class ConnectionController {
694695
}
695696

696697
public getConnectionStringFromConnectionId(connectionId: string): string {
697-
return this._connections[connectionId].driverUrl;
698+
return this._connections[connectionId].connectionModel.driverUrlWithSsh;
698699
}
699700

700701
public isCurrentlyConnected(): boolean {
@@ -726,9 +727,7 @@ export default class ConnectionController {
726727
}
727728

728729
public getConnectionStatusStringForConnection(connectionId: string): string {
729-
if (
730-
this.getActiveConnectionId() === connectionId
731-
) {
730+
if (this.getActiveConnectionId() === connectionId) {
732731
if (this.isDisconnecting()) {
733732
return 'disconnecting...';
734733
}
@@ -738,8 +737,7 @@ export default class ConnectionController {
738737

739738
if (
740739
this.isConnecting() &&
741-
this.getConnectingConnectionId() ===
742-
connectionId
740+
this.getConnectingConnectionId() === connectionId
743741
) {
744742
return 'connecting...';
745743
}

src/connectionModelType.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ type ConnectionAttributes = {
99
export type ConnectionModelType = {
1010
appname: string;
1111
port: number;
12-
12+
driverUrl: string;
13+
driverUrlWithSsh: string;
1314
getAttributes(options: object): ConnectionAttributes;
1415
disconnect(callback: (n: Error | undefined) => void): void;
1516
};

0 commit comments

Comments
 (0)