Skip to content

Commit bbb98e5

Browse files
authored
Merge pull request #950 from rocket-admin/backend_test_dynamo_db
rework DynamoDB connection string parser to extract credentials and format host
2 parents 32c3ba1 + f74647e commit bbb98e5

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

backend/src/helpers/parsers/string-connection-to-database-parsers.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,15 @@ export const parseTestIbmDB2ConnectionString = (connectionString: string): Parti
147147

148148
// dynamodb://accessKeyId:secretAccessKey@localhost:8000/
149149
export const parseTestDynamoDBConnectionString = (connectionString: string): Partial<CreateConnectionDto> => {
150-
const url = new URL(connectionString);
150+
const modifiedConnectionString = connectionString.replace('dynamodb://', '');
151+
const [credentials, nestedUrl] = modifiedConnectionString.split('@');
152+
const [username, password] = credentials.split(':');
153+
const url = new URL(nestedUrl);
151154
const config: Partial<CreateConnectionDto> = {};
152-
153-
config.username = url.username || null;
154-
config.password = url.password || null;
155-
config.host = url.hostname || null;
155+
config.username = username || null;
156+
config.password = password || null;
157+
const host = `${url.protocol}//${url.hostname}:${url.port}`;
158+
config.host = host;
156159
config.type = ConnectionTypesEnum.dynamodb;
157160
config.title = 'DynamoDB';
158161
config.isTestConnection = true;

0 commit comments

Comments
 (0)