Skip to content

Commit

Permalink
Accepts regex flags
Browse files Browse the repository at this point in the history
  • Loading branch information
jinzhu committed Jun 25, 2020
1 parent 4966f54 commit c8164cd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
9 changes: 8 additions & 1 deletion lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,16 @@ function getLabelRegexesMapFromObject(configObject) {
return labelRegexes;
}
function checkRegexes(issue_body, regexes) {
var found;
// If several regex entries are provided we require all of them to match for the label to be applied.
for (const regEx of regexes) {
const found = issue_body.match(regEx);
const isRegEx = regEx.match(/^\/(.+)\/(.*)$/);
if (isRegEx) {
found = issue_body.match(new RegExp(isRegEx[1], isRegEx[2]));
}
else {
found = issue_body.match(regEx);
}
if (!found) {
return false;
}
Expand Down
10 changes: 9 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,18 @@ function getLabelRegexesMapFromObject(configObject: any): Map<string, string[]>
}

function checkRegexes(issue_body: string, regexes: string[]): boolean {
var found;

// If several regex entries are provided we require all of them to match for the label to be applied.
for (const regEx of regexes) {
const found = issue_body.match(regEx)
const isRegEx = regEx.match(/^\/(.+)\/(.*)$/)

if (isRegEx) {
found = issue_body.match(new RegExp(isRegEx[1], isRegEx[2]))
} else {
found = issue_body.match(regEx)
}

if (!found) {
return false;
}
Expand Down

0 comments on commit c8164cd

Please sign in to comment.