Skip to content

Commit

Permalink
fix: Remove carriage return injected by issue edits
Browse files Browse the repository at this point in the history
Signed-off-by: Tomas Coufal <tcoufal@redhat.com>
  • Loading branch information
tumido committed Nov 9, 2022
1 parent 7748403 commit 22ac223
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions packages/probot-issue-form/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,17 @@ describe('parse', () => {
expect(data).toEqual({ thisIsInput: 'value' });
});

it('single input with carriage return', async () => {
const context = {
payload: { issue: { body: '### This is input field\r\n\r\nvalue' } },
log: console,
};

const data = await parser.parse(context);

expect(data).toEqual({ thisIsInput: 'value' });
});

it('no match', async () => {
const context = {
payload: { issue: { body: '### Something else\n\nvalue' } },
Expand Down
3 changes: 2 additions & 1 deletion packages/probot-issue-form/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ export const fetchTemplates = async (context: any): Promise<File[]> => {
export const parse = async (
context: any
): Promise<Record<string, string | string[]>> => {
const body = context.payload.issue.body || '';
const body =
(context.payload.issue.body as string).replaceAll('\r\n', '\n') || '';
const templates = (await fetchTemplates(context))
.map((f) => ({
file: f,
Expand Down

0 comments on commit 22ac223

Please # to comment.