MCPcopy Create free account
hub / github.com/TruthHun/BookStack / createEscaper

Function createEscaper

static/bootstrap-select-1.13.18/js/bootstrap-select.js:561–573  ·  view source on GitHub ↗
(map)

Source from the content-addressed store, hash-verified

559
560 // Functions for escaping and unescaping strings to/from HTML interpolation.
561 var createEscaper = function (map) {
562 var escaper = function (match) {
563 return map[match];
564 };
565 // Regexes for identifying a key that needs to be escaped.
566 var source = '(?:' + Object.keys(map).join('|') + ')';
567 var testRegexp = RegExp(source);
568 var replaceRegexp = RegExp(source, 'g');
569 return function (string) {
570 string = string == null ? '' : '' + string;
571 return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string;
572 };
573 };
574
575 var htmlEscape = createEscaper(escapeMap);
576

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected