Skip to content

Commit

Permalink
Merge pull request #59 from tumido/fix-carriage-return
Browse files Browse the repository at this point in the history
fix: Remove carriage return injected by issue edits
  • Loading branch information
HumairAK authored Nov 9, 2022
2 parents 7748403 + 22ac223 commit 1a04c67
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 1a04c67

Please # to comment.