Browse Source

Merge pull request #132 in DEC/decision-webui-dcm from ~ALAN/decision-webui-dcm:release/10.0 to release/10.0

* commit '454e3c026ed18cf319900ce8ce75d7e76aaf3963':
  fix: DEC-10992 修复数据库名包含特殊符号的问题
research/10.0
alan 5 years ago
parent
commit
21723938ca
  1. 16
      src/modules/__test__/app.test.ts
  2. 2
      src/modules/app.service.ts

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

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

Loading…
Cancel
Save