From 8e6e3464ad396856ad3c57b8cb5fea766e22d9a5 Mon Sep 17 00:00:00 2001 From: alan Date: Mon, 6 Jan 2020 15:45:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20DEC-11782=20oracle=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5url=E7=AB=AF=E5=8F=A3=E5=8F=B7=E5=92=8C?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E4=B9=8B=E9=97=B4=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E6=98=AF/=E6=88=96:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/__test__/app.test.ts | 12 ++++++++++++ src/modules/app.service.ts | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/modules/__test__/app.test.ts b/src/modules/__test__/app.test.ts index e61efc5..d1a205f 100644 --- a/src/modules/__test__/app.test.ts +++ b/src/modules/__test__/app.test.ts @@ -58,6 +58,18 @@ test('解析url', () => { databaseName: 'database', urlInfo: '', }); + expect(resolveUrlInfo('jdbc:oracle:thin:@192.168.5.143:1521/orcl')).toEqual({ + host: '192.168.5.143', + port: '1521', + databaseName: 'orcl', + urlInfo: '', + }); + expect(resolveUrlInfo('jdbc:oracle:thin:@192.168.5.143:1521:orcl')).toEqual({ + host: '192.168.5.143', + port: '1521', + databaseName: 'orcl', + urlInfo: '', + }); }); test('数据库可能为空', () => { diff --git a/src/modules/app.service.ts b/src/modules/app.service.ts index c193cbe..5a06d77 100644 --- a/src/modules/app.service.ts +++ b/src/modules/app.service.ts @@ -49,7 +49,7 @@ export function getJdbcDatabaseType(database: string, driver: string): DatabaseT export function resolveUrlInfo (url: string) { if (BI.isNull(url)) return {}; - const oracleUlr = url.match(/^jdbc:(oracle):(thin:([0-9a-zA-Z/]*)?@|thin:([0-9a-zA-Z/]*)?@\/\/|\/\/|)([0-9a-zA-Z_\\.-]+)(:([0-9|port]+))?(:)([^]+)(.*)/i); + const oracleUlr = url.match(/^jdbc:(oracle):(thin:([0-9a-zA-Z/]*)?@|thin:([0-9a-zA-Z/]*)?@\/\/|\/\/|)([0-9a-zA-Z_\\.-]+)(:([0-9|port]+))?(:|\/)([^]+)(.*)/i); if (oracleUlr) { return { host: oracleUlr[5],