zxhlyh 7a1d6fe509
Feat/attachments (#9526)
Co-authored-by: Joel <iamjoel007@gmail.com>
Co-authored-by: JzoNg <jzongcode@gmail.com>
2024-10-21 10:32:37 +08:00

22 lines
500 B
TypeScript

import { type BodyPayload, BodyPayloadValueType } from './types'
export const transformToBodyPayload = (old: string, hasKey: boolean): BodyPayload => {
if (!hasKey) {
return [
{
type: BodyPayloadValueType.text,
value: old,
},
]
}
const bodyPayload = old.split('\n').map((item) => {
const [key, value] = item.split(':')
return {
key: key || '',
type: BodyPayloadValueType.text,
value: value || '',
}
})
return bodyPayload
}