Skip to content

Commit

Permalink
refactor: case sensitivity and require brackets handling in validate.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
tsinis committed Apr 9, 2024
1 parent e1bf18e commit bb8cdb5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
11 changes: 5 additions & 6 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 6 additions & 9 deletions src/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,16 @@ export async function validate({
let strategy: Strategy | undefined = undefined;
fallbackToAsk = fallbackToAsk !== undefined ? fallbackToAsk : false;
const client = github.getOctokit(token, octokitOpts);
caseSensitive = String(caseSensitive).toLowerCase() === "true";
console.log(`Case Sensitive: ${caseSensitive}`);
requireBrackets = String(requireBrackets).toLowerCase() === "true";
console.log(`Require Brackets: ${requireBrackets}`);
const regex = buildRegexPattern(
shipKeyword || Strategy.Ship,
showKeyword || Strategy.Show,
askKeyword || Strategy.Ask,
requireBrackets !== undefined ? requireBrackets : true,
caseSensitive !== undefined ? caseSensitive : false,
requireBrackets,
caseSensitive,
);

try {
Expand All @@ -66,17 +70,10 @@ export async function validate({
});

console.log(`Regex: ${regex}`);
console.log(`Case Sensitive: ${caseSensitive}`);
const title = pr.title.trim().normalize().replace(/"/g, "");
console.log(`Actual PR Title Before Match: "${title}"`);
const match = title.match(regex);
console.log(`Match Result: ${match}`);
console.log(
title
.split("")
.map((c) => c.charCodeAt(0).toString(16))
.join(" "),
);

if (match) {
// Extract the keyword from the match
Expand Down

0 comments on commit bb8cdb5

Please sign in to comment.