Skip to content

Commit

Permalink
fix: remove email from qmsg content
Browse files Browse the repository at this point in the history
  • Loading branch information
imaegoo committed Sep 5, 2024
1 parent d648ec8 commit 8b15a44
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pushoo",
"version": "0.1.4",
"version": "0.1.5",
"description": "Instant Messaging Pushing SDK",
"keywords": [
"pushoojs",
Expand Down
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,12 @@ function getTitle(content: string) {
function removeUrlAndIp(content: string) {
const urlRegex = /(https?:\/\/[^\s]+)/g;
const ipRegex = /(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/g;
return content.replace(urlRegex, '').replace(ipRegex, '');
// 邮箱正则表达式来自 https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email#validation
const mailRegExp = /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*/g;
return content
.replace(urlRegex, '')
.replace(ipRegex, '')
.replace(mailRegExp, '');
}

/**
Expand Down

0 comments on commit 8b15a44

Please sign in to comment.