mirror of https://github.com/nocodb/nocodb
mertmit
2 years ago
11 changed files with 25 additions and 14 deletions
@ -1,7 +1,17 @@ |
|||||||
export default function extractProps<T>(body: T, props: string[]): Partial<T> { |
import DOMPurify from 'isomorphic-dompurify'; |
||||||
|
|
||||||
|
export function extractProps<T>(body: T, props: string[]): Partial<T> { |
||||||
// todo: throw error if no props found
|
// todo: throw error if no props found
|
||||||
return props.reduce((o, key) => { |
return props.reduce((o, key) => { |
||||||
if (key in body) o[key] = body[key]; |
if (key in body) o[key] = body[key]; |
||||||
return o; |
return o; |
||||||
}, {}); |
}, {}); |
||||||
} |
} |
||||||
|
|
||||||
|
export function extractPropsAndSanitize<T>(body: T, props: string[]): Partial<T> { |
||||||
|
// todo: throw error if no props found
|
||||||
|
return props.reduce((o, key) => { |
||||||
|
if (key in body) o[key] = DOMPurify.sanitize(body[key]); |
||||||
|
return o; |
||||||
|
}, {}); |
||||||
|
} |
||||||
|
Loading…
Reference in new issue