From e70ae853cae67e399dd0a98f3015413ea71e4468 Mon Sep 17 00:00:00 2001 From: Nico Korthout Date: Fri, 29 Oct 2021 12:47:03 +0200 Subject: [PATCH] fix(github): pull body can be null --- src/github.ts | 2 +- src/utils.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/github.ts b/src/github.ts index c14eee7..3bed055 100644 --- a/src/github.ts +++ b/src/github.ts @@ -87,7 +87,7 @@ export class Github implements GithubApi { export type PullRequest = { number: number; title: string; - body: string; + body: string | null; head: { sha: string; }; diff --git a/src/utils.ts b/src/utils.ts index c5424c6..3d46b88 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -19,7 +19,7 @@ export function composeBody( type PullRequest = { number: number; - body: string; + body: string | null; user: { login: string; }; @@ -29,10 +29,10 @@ type PullRequest = { * @param body Text in which to search for mentioned issues * @returns All found mentioned issues as GitHub issue references */ -export function getMentionedIssueRefs(body: string): string[] { +export function getMentionedIssueRefs(body: string | null): string[] { const issueUrls = - body.match(patterns.url.global)?.map((url) => toRef(url)) ?? []; - const issueRefs = body.match(patterns.ref) ?? []; + body?.match(patterns.url.global)?.map((url) => toRef(url)) ?? []; + const issueRefs = body?.match(patterns.ref) ?? []; return issueUrls.concat(issueRefs).map((ref) => ref.trim()); }