main
Last change
on this file since e48199a was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
358 bytes
|
Rev | Line | |
---|
[d24f17c] | 1 |
|
---|
| 2 | var XML_CHARACTER_MAP = {
|
---|
| 3 | '&': '&',
|
---|
| 4 | '"': '"',
|
---|
| 5 | "'": ''',
|
---|
| 6 | '<': '<',
|
---|
| 7 | '>': '>'
|
---|
| 8 | };
|
---|
| 9 |
|
---|
| 10 | function escapeForXML(string) {
|
---|
| 11 | return string && string.replace
|
---|
| 12 | ? string.replace(/([&"<>'])/g, function(str, item) {
|
---|
| 13 | return XML_CHARACTER_MAP[item];
|
---|
| 14 | })
|
---|
| 15 | : string;
|
---|
| 16 | }
|
---|
| 17 |
|
---|
| 18 | module.exports = escapeForXML;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.