Skip to content

Commit

Permalink
fix: check for column content before replacing
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Jun 30, 2020
1 parent 1e0b830 commit bd4563d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/workers/pr/body/updates-table.ts
Expand Up @@ -62,8 +62,8 @@ export function getPrUpdatesTable(config: BranchConfig): string {
let val = '|';
for (const column of tableColumns) {
const content = row[column]
.replace(/^@/, '@​')
.replace(/\|/g, '\\|');
? row[column].replace(/^@/, '@​').replace(/\|/g, '\\|')
: '';

This comment has been minimized.

Copy link
@viceice

viceice Jun 30, 2020

Member

@rarkins This can be simplified to row[column]?.replace(/^@/, '@​').replace(/\|/g, '\\|') ?? '' 🙃

You should use ?. operator more often 😅

This comment has been minimized.

Copy link
@rarkins

rarkins Jun 30, 2020

Author Collaborator

It's the ?? operator I'm not really familiar with actually

This comment has been minimized.

Copy link
@viceice

viceice Jun 30, 2020

Member

it's like || but only executes the right side if the left is null | undefined

This comment has been minimized.

Copy link
@viceice

viceice Jun 30, 2020

Member

so (0 || 1) === 1 but (0 ?? 1) === 0

val += ` ${content} |`;
}
val += '\n';
Expand Down

0 comments on commit bd4563d

Please sign in to comment.