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],