Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix task assignee regex can't accept multi-level domains #49685

Merged
merged 10 commits into from
Sep 30, 2024
5 changes: 3 additions & 2 deletions src/pages/home/report/ReportFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,14 @@
* Group 2: Optional email group between \s+....\s* start rule with @+valid email or short mention
* Group 3: Title is remaining characters
*/
const taskRegex = /^\[\]\s+(?:@([^\s@]+(?:@\w+\.\w+)?))?\s*([\s\S]*)/;
const emailWithOptionalDomainRegex = /(?=((?=[\w'#%+-]+(?:\.[\w'#%+-]+)*@?)[\w\.'#%+-]{1,64}(?:@(?:(?=[a-z\d]+(?:-+[a-z\d]+)*\.)(?:[a-z\d-]{1,63}\.)+[a-z]{2,63}))?(?= |_|\b))(?<end>.*))\S{3,254}(?=\k<end>$)/

Check failure on line 132 in src/pages/home/report/ReportFooter.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Replace `·/(?=((?=[\w'#%+-]+(?:\.[\w'#%+-]+)*@?)[\w\.'#%+-]{1,64}(?:@(?:(?=[a-z\d]+(?:-+[a-z\d]+)*\.)(?:[a-z\d-]{1,63}\.)+[a-z]{2,63}))?(?=·|_|\b))(?<end>.*))\S{3,254}(?=\k<end>$)/` with `⏎················/(?=((?=[\w'#%+-]+(?:\.[\w'#%+-]+)*@?)[\w\.'#%+-]{1,64}(?:@(?:(?=[a-z\d]+(?:-+[a-z\d]+)*\.)(?:[a-z\d-]{1,63}\.)+[a-z]{2,63}))?(?=·|_|\b))(?<end>.*))\S{3,254}(?=\k<end>$)/;`

Check failure on line 132 in src/pages/home/report/ReportFooter.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Unnecessary escape character: \.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to use the email regex from expensify-common. The only differences is the optional domain.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I just removed the unnecessary character because the linter asked to.

const taskRegex = `^\\[\\]\\s+(?:@(?:${emailWithOptionalDomainRegex.source}))?\\s*([\\s\\S]*)`;

const match = text.match(taskRegex);
if (!match) {
return false;
}
const title = match[2] ? match[2].trim().replace(/\n/g, ' ') : undefined;
const title = match[3] ? match[3].trim().replace(/\n/g, ' ') : undefined;
if (!title) {
return false;
}
Expand Down
Loading