2018-10-18 14:40:35 +02:00
|
|
|
// @flow
|
|
|
|
|
export type Description = {
|
|
|
|
|
title: string,
|
|
|
|
|
message: string
|
|
|
|
|
};
|
|
|
|
|
|
2018-10-24 10:25:50 +02:00
|
|
|
export function parseDescription(description?: string): Description {
|
|
|
|
|
const desc = description ? description : "";
|
|
|
|
|
const lineBreak = desc.indexOf("\n");
|
2018-10-18 14:40:35 +02:00
|
|
|
|
|
|
|
|
let title;
|
|
|
|
|
let message = "";
|
|
|
|
|
|
|
|
|
|
if (lineBreak > 0) {
|
2018-10-24 10:25:50 +02:00
|
|
|
title = desc.substring(0, lineBreak);
|
|
|
|
|
message = desc.substring(lineBreak + 1);
|
2018-10-18 14:40:35 +02:00
|
|
|
} else {
|
2018-10-24 10:25:50 +02:00
|
|
|
title = desc;
|
2018-10-18 14:40:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
title,
|
|
|
|
|
message
|
|
|
|
|
};
|
|
|
|
|
}
|