From 9e9a90b41ece048c90aac520853c846ccd4a5a76 Mon Sep 17 00:00:00 2001 From: Pavish Kumar Date: Fri, 8 Oct 2021 17:47:46 +0530 Subject: [PATCH] Retain spaces within label (#95) --- __tests__/issue.test.ts | 14 ++++++++++++++ dist/index.js | 2 +- src/issue.ts | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/__tests__/issue.test.ts b/__tests__/issue.test.ts index 4e58042..fbffd8d 100644 --- a/__tests__/issue.test.ts +++ b/__tests__/issue.test.ts @@ -41,6 +41,20 @@ describe('getIssueOption', () => { } expect(issue.getIssueOption('hi')).toEqual(expected) }) + + test('with label containing spaces', () => { + process.env.INPUT_ISSUE_TITLE = 'npm audit found vulnerabilities' + process.env.INPUT_ISSUE_ASSIGNEES = 'alice' + process.env.INPUT_ISSUE_LABELS = 'status: ready, work: frontend' + + const expected: IssueOption = { + title: 'npm audit found vulnerabilities', + body: 'hi', + assignees: ['alice'], + labels: ['status: ready', 'work: frontend'] + } + expect(issue.getIssueOption('hi')).toEqual(expected) + }) }) describe('getExistingIssueNumber', () => { diff --git a/dist/index.js b/dist/index.js index 2299c3a..3b9348f 100644 --- a/dist/index.js +++ b/dist/index.js @@ -104,7 +104,7 @@ function getIssueOption(body) { assignees = core.getInput('issue_assignees').replace(/\s+/g, '').split(','); } if (core.getInput('issue_labels')) { - labels = core.getInput('issue_labels').replace(/\s+/g, '').split(','); + labels = core.getInput('issue_labels').split(',').map(label => label.trim()); } return { title: core.getInput('issue_title'), diff --git a/src/issue.ts b/src/issue.ts index 88c4e27..3085bb8 100644 --- a/src/issue.ts +++ b/src/issue.ts @@ -9,7 +9,7 @@ export function getIssueOption(body: string): IssueOption { assignees = core.getInput('issue_assignees').replace(/\s+/g, '').split(',') } if (core.getInput('issue_labels')) { - labels = core.getInput('issue_labels').replace(/\s+/g, '').split(',') + labels = core.getInput('issue_labels').split(',').map(label => label.trim()) } return {