Skip to content

Commit

Permalink
fix: made label extraction system more resilient
Browse files Browse the repository at this point in the history
  • Loading branch information
arctic-hen7 committed Jan 8, 2022
1 parent 92f4998 commit 1f80431
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90814,12 +90814,12 @@ const newIssueHandler = async (ctx) => {
const getRequestedLabels = (issueBody) => {
// The relevant `<details>` block in a Tribble-formatted issue will always come at the end
// We add to this because we need to get the actual contained text
const detailsOpenIdx = issueBody.lastIndexOf("<details>\n<summary>Tribble internal data</summary>") + 51;
const detailsOpenIdx = issueBody.lastIndexOf("</summary>") + 10;
const detailsCloseIdx = issueBody.lastIndexOf("</details>");
console.log(detailsOpenIdx);
console.log(detailsCloseIdx);
// The indexing will return `-1` if it found nothing (but one had 51 added)
if (detailsOpenIdx === 50 || detailsCloseIdx === -1) {
// The indexing will return `-1` if it found nothing (but one had 10 added)
if (detailsOpenIdx === 9 || detailsCloseIdx === -1) {
return undefined;
}
const encoded = issueBody.substring(detailsOpenIdx, detailsCloseIdx).trim();
Expand Down
6 changes: 3 additions & 3 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ const newIssueHandler = async (ctx) => {
const getRequestedLabels = (issueBody) => {
// The relevant `<details>` block in a Tribble-formatted issue will always come at the end
// We add to this because we need to get the actual contained text
const detailsOpenIdx = issueBody.lastIndexOf("<details>\n<summary>Tribble internal data</summary>") + 51;
const detailsOpenIdx = issueBody.lastIndexOf("</summary>") + 10;
const detailsCloseIdx = issueBody.lastIndexOf("</details>");
console.log(detailsOpenIdx);
console.log(detailsCloseIdx);
// The indexing will return `-1` if it found nothing (but one had 51 added)
if (detailsOpenIdx === 50 || detailsCloseIdx === -1) {
// The indexing will return `-1` if it found nothing (but one had 10 added)
if (detailsOpenIdx === 9 || detailsCloseIdx === -1) {
return undefined;
}
const encoded = issueBody.substring(detailsOpenIdx, detailsCloseIdx).trim();
Expand Down

0 comments on commit 1f80431

Please sign in to comment.