top 10 boilerplate ever
This commit is contained in:
commit
153c74bd22
17 changed files with 567 additions and 0 deletions
18
common/format.js
Normal file
18
common/format.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
const escapeCodes = {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
"'": ''',
|
||||
'"': '"'
|
||||
};
|
||||
|
||||
let format = {};
|
||||
|
||||
format.escape = function (str) {
|
||||
return str.replaceAll(
|
||||
/[&<>'"]/g,
|
||||
tag => escapeCodes[tag]
|
||||
)
|
||||
};
|
||||
|
||||
export default format;
|
Loading…
Add table
Add a link
Reference in a new issue