Created
February 17, 2016 03:27
-
-
Save JerryC8080/85a5344c5a4fa42383eb to your computer and use it in GitHub Desktop.
邮箱字符遮罩
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 邮箱字符遮罩 | |
* @param email | |
* @returns {string} | |
* @private | |
*/ | |
function _hideEmail(email) { | |
var accounts = email.split('@')[0]; | |
var suffix = email.split('@')[1]; | |
var hideNums = Math.floor(accounts.length/2); | |
var hideAccounts = accounts.split(''); | |
for (var i = 0; i < hideNums; i++) { | |
hideAccounts[i+1] = '*'; | |
} | |
return hideAccounts.join('') + '@' + suffix; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment