Skip to content

Commit

Permalink
moving label toLowercase code up to top of function
Browse files Browse the repository at this point in the history
  • Loading branch information
lannonbr committed Mar 5, 2022
1 parent 587418b commit 45dd92f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ function diffLabels(oldLabels, newLabels) {
// each entry has two values
// { type: 'create' | 'update' | 'delete', label }

let oldLabelsNames = oldLabels.map((label) => label.name);
let newLabelsNames = newLabels.map((label) => label.name);
let oldLabelsNames = oldLabels.map((label) => label.name.toLowerCase());
let newLabelsNames = newLabels.map((label) => label.name.toLowerCase());

let labelModList = [];

oldLabelsNames.forEach((oLabel) => {
// when using `includes` with strings, the match is case-sensitive
// so we first lowercase both strings when comparing
if (newLabelsNames.toLowerCase().includes(oLabel.toLowerCase())) {
if (newLabelsNames.includes(oLabel)) {
const oldLabel = oldLabels.filter((l) => l.name === oLabel)[0];
const newLabel = newLabels.filter((l) => l.name === oLabel)[0];

Expand Down

0 comments on commit 45dd92f

Please sign in to comment.