Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace line breaks with space for issue summary and search query #135

Merged
merged 1 commit into from Feb 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions jirabot/dist/main.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions jirabot/src/message.ts
Expand Up @@ -413,7 +413,7 @@ export const parseMessage = async (
return {
context: messageContext,
type: BotMessageType.Create,
name: rest[0],
name: Utils.linebreaksToSpaces(rest[0]),
project: getProjectRet.result,
assignee,
description: rest.slice(1).join(' '),
Expand Down Expand Up @@ -460,7 +460,7 @@ export const parseMessage = async (
return {
context: messageContext,
type: BotMessageType.Search,
query: rest.join(' '),
query: Utils.linebreaksToSpaces(rest.join(' ')),
project: getProjectRet.result,
assignee,
status: args.status,
Expand Down
2 changes: 1 addition & 1 deletion jirabot/src/utils.test.js
Expand Up @@ -9,6 +9,6 @@ test('split2', () => {
{input: `5abc it's it`, output: ['5abc', "it's", 'it']},
{input: `6abc it's "it it"`, output: ['6abc', "it's", 'it it']},
{input: `7abc 'abc "it it"'`, output: ['7abc', `abc "it it"`]},
{input: `a\nb\r\nc\rd`, output: ['a', 'b', 'c', 'd']},
].forEach(({input, output}) => expect(Utils.split2(input)).toEqual(output))
})

7 changes: 5 additions & 2 deletions jirabot/src/utils.ts
Expand Up @@ -13,8 +13,8 @@ const quotes: {
'‘': '’',
}

const spaces = [' ', '\n', '\t']
const spacesRE = / |\n|\t/
const spaces = [' ', '\n', '\r', '\t']
const spacesRE = / |\r\n|\n|\r|\t/

// splits a string by white space, but respect quotes
export const split2 = (s: string) => {
Expand Down Expand Up @@ -112,3 +112,6 @@ export const randomString = (prefix: string): Promise<string> =>
err ? reject(err) : resolve(`${prefix}-${buf.toString('hex')}`)
})
)

export const linebreaksToSpaces = (str: string): string =>
str.replace(/\r\n|\r|\n/g, ' ')