Commit aa5aca1697d6d88a2409d84cf39c77a1b3dc7f8d
1 parent
9af92dbb
Exists in
master
and in
3 other branches
fix: 修复工具方法正则表达式及ESLint提示
Showing
1 changed file
with
4 additions
and
2 deletions
Show diff stats
packages/form/util.js
| @@ -50,7 +50,8 @@ export const cloneDeep = obj => { | @@ -50,7 +50,8 @@ export const cloneDeep = obj => { | ||
| 50 | export const get = (obj, dotSeparatedKeys) => { | 50 | export const get = (obj, dotSeparatedKeys) => { |
| 51 | if (dotSeparatedKeys !== undefined && typeof dotSeparatedKeys !== 'string') return undefined; | 51 | if (dotSeparatedKeys !== undefined && typeof dotSeparatedKeys !== 'string') return undefined; |
| 52 | if (typeof obj !== 'undefined' && typeof dotSeparatedKeys === 'string') { | 52 | if (typeof obj !== 'undefined' && typeof dotSeparatedKeys === 'string') { |
| 53 | - const splitRegex = /[.[]'"]/g; | 53 | + // eslint-disable-next-line no-useless-escape |
| 54 | + const splitRegex = /[.\[\]'"]/g; | ||
| 54 | const pathArr = dotSeparatedKeys.split(splitRegex).filter(k => k !== ''); | 55 | const pathArr = dotSeparatedKeys.split(splitRegex).filter(k => k !== ''); |
| 55 | obj = pathArr.reduce((o, key) => (o && o[key] !== undefined ? o[key] : undefined), obj); | 56 | obj = pathArr.reduce((o, key) => (o && o[key] !== undefined ? o[key] : undefined), obj); |
| 56 | } | 57 | } |
| @@ -66,7 +67,8 @@ export const get = (obj, dotSeparatedKeys) => { | @@ -66,7 +67,8 @@ export const get = (obj, dotSeparatedKeys) => { | ||
| 66 | * @example set(obj, 'a.b.c', 'd') | 67 | * @example set(obj, 'a.b.c', 'd') |
| 67 | */ | 68 | */ |
| 68 | export const set = (obj, dotSeparatedKeys, value) => { | 69 | export const set = (obj, dotSeparatedKeys, value) => { |
| 69 | - const splitRegex = /[.[]'"]/g; | 70 | + // eslint-disable-next-line no-useless-escape |
| 71 | + const splitRegex = /[.\[\]'"]/g; | ||
| 70 | const pathArr = dotSeparatedKeys.split(splitRegex).filter(k => k !== ''); | 72 | const pathArr = dotSeparatedKeys.split(splitRegex).filter(k => k !== ''); |
| 71 | const key = pathArr.pop(); | 73 | const key = pathArr.pop(); |
| 72 | pathArr.reduce((o, k) => { | 74 | pathArr.reduce((o, k) => { |