From d7b83b33bdd9a5c2e49c2280a684ac50939dc3b6 Mon Sep 17 00:00:00 2001 From: DarkPhoenix2704 Date: Mon, 4 Nov 2024 13:17:32 +0000 Subject: [PATCH] fix: normalize endpoint url --- packages/nocodb/src/plugins/mino/Minio.ts | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/packages/nocodb/src/plugins/mino/Minio.ts b/packages/nocodb/src/plugins/mino/Minio.ts index 7304065428..2cdd83d169 100644 --- a/packages/nocodb/src/plugins/mino/Minio.ts +++ b/packages/nocodb/src/plugins/mino/Minio.ts @@ -22,7 +22,28 @@ export default class Minio implements IStorageAdapterV2 { private input: MinioObjectStorageInput; constructor(input: unknown) { - this.input = input as MinioObjectStorageInput; + this.input = this.normalizeInput(input as MinioObjectStorageInput); + } + + private normalizeInput(input: MinioObjectStorageInput) { + let endPoint = input.endPoint; + let useSSL = input.useSSL; + + if (endPoint.startsWith('http://')) { + endPoint = endPoint.replace('http://', ''); + useSSL = false; + } else if (endPoint.startsWith('https://')) { + useSSL = true; + endPoint = endPoint.replace('https://', ''); + } + + endPoint = endPoint.trim().replace(/\/+$/, ''); + + return { + ...input, + endPoint, + useSSL, + }; } public async init(): Promise {