From 454e3c026ed18cf319900ce8ce75d7e76aaf3963 Mon Sep 17 00:00:00 2001 From: alan Date: Mon, 18 Nov 2019 10:08:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20DEC-10992=20=E4=BF=AE=E5=A4=8D=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E5=90=8D=E5=8C=85=E5=90=AB=E7=89=B9=E6=AE=8A?= =?UTF-8?q?=E7=AC=A6=E5=8F=B7=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/__test__/app.test.ts | 16 +++++++++++++++- src/modules/app.service.ts | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/modules/__test__/app.test.ts b/src/modules/__test__/app.test.ts index 5b8cf72..07ded52 100644 --- a/src/modules/__test__/app.test.ts +++ b/src/modules/__test__/app.test.ts @@ -1,11 +1,25 @@ -import { connectionCanEdit } from '../app.service'; +import { connectionCanEdit, resolveUrlInfo } from '../app.service'; const connection = { connectionId: '', connectionType: '', connectionName: '', connectionData: '', }; +/** + * test_author_alan + */ +test('DEC-10992 数据连接名称带-', () => { + expect(resolveUrlInfo('jdbc:sqlserver://192.168.17.111:1433;databaseName=L-Pick-DAS-MengYan')).toEqual({ + host: '192.168.17.111', + port: '1433', + databaseName: 'L-Pick-DAS-MengYan', + urlInfo: '', + }); +}); +/** + * test_author_alan + */ test('BI-51537 判断数据连接是否有权限', () => { expect(connectionCanEdit({ ...connection, diff --git a/src/modules/app.service.ts b/src/modules/app.service.ts index a7fe9be..c51f1d9 100644 --- a/src/modules/app.service.ts +++ b/src/modules/app.service.ts @@ -47,7 +47,7 @@ export function getJdbcDatabaseType(database: string, driver: string): DatabaseT export function resolveUrlInfo (url: string) { if (BI.isNull(url)) return {}; - const result = url.match(/^jdbc:(oracle|mysql|sqlserver|db2|impala|kylin|phoenix|derby|gbase|gbasedbt-sqli|informix-sqli|h2|postgresql|hive2|vertica|kingbase|presto):(thin:([0-9a-zA-Z/]*)?@|thin:([0-9a-zA-Z/]*)?@\/\/|\/\/|)([0-9a-zA-Z_\\.-]+)(:([0-9|port]+))?(:|\/|;DatabaseName=)([0-9a-zA-Z_\\.]+)(.*)/i); + const result = url.match(/^jdbc:(oracle|mysql|sqlserver|db2|impala|kylin|phoenix|derby|gbase|gbasedbt-sqli|informix-sqli|h2|postgresql|hive2|vertica|kingbase|presto):(thin:([0-9a-zA-Z/]*)?@|thin:([0-9a-zA-Z/]*)?@\/\/|\/\/|)([0-9a-zA-Z_\\.-]+)(:([0-9|port]+))?(:|\/|;DatabaseName=)([^]+)(.*)/i); if (result) { return { host: result[5],