forked from esamattis/underscore.string
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathescapeHTML.js
More file actions
Latest commit
18 lines (14 loc) · 420 Bytes
/
Copy pathescapeHTML.js
File metadata and controls
18 lines (14 loc) · 420 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
varmakeString=require('./helper/makeString');
varescapeChars=require('./helper/escapeChars');
varreversedEscapeChars={};
varregexString="[";
for(varkeyinescapeChars){
regexString+=key;
}
regexString+="]";
varregex=newRegExp(regexString,'g');
module.exports=functionescapeHTML(str){
returnmakeString(str).replace(regex,function(m){
return'&'+escapeChars[m]+';';
});
};