Skip to content

Commit

Permalink
Cater for body being nullish or empty
Browse files Browse the repository at this point in the history
  • Loading branch information
greglockwood committed Jan 9, 2021
1 parent dea4054 commit 1c5dec2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion github.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ function readGHKey() {
* @param {string} body
*/
function upsertNavigationInBody(newNavigation, body) {
body = body || '';
if (body.match(/<pr-train-toc>/)) {
return body.replace(/<pr-train-toc>[^]*<\/pr-train-toc>/, newNavigation);
} else {
return body + '\n' + newNavigation;
return (body ? body + '\n' : '') + newNavigation;
}
}

Expand Down

0 comments on commit 1c5dec2

Please sign in to comment.