Sha256: 86ee986c663526c0c2ccfa0399a837ce5426d48cfdcb0d079a0d89a9d2e6f2f7

Contents?: true

Size: 935 Bytes

Versions: 44

Compression:

Stored size: 935 Bytes

Contents

/**
 * @fileoverview XML character escaper
 * @author George Chung
 */
"use strict";

//------------------------------------------------------------------------------
// Public Interface
//------------------------------------------------------------------------------

/**
 * Returns the escaped value for a character
 * @param {string} s string to examine
 * @returns {string} severity level
 * @private
 */
module.exports = function(s) {
    return (`${s}`).replace(/[<>&"'\x00-\x1F\x7F\u0080-\uFFFF]/g, c => { // eslint-disable-line no-control-regex
        switch (c) {
            case "<":
                return "&lt;";
            case ">":
                return "&gt;";
            case "&":
                return "&amp;";
            case "\"":
                return "&quot;";
            case "'":
                return "&apos;";
            default:
                return `&#${c.charCodeAt(0)};`;
        }
    });
};

Version data entries

44 entries across 44 versions & 2 rubygems

Version Path
govuk_publishing_components-18.0.0 node_modules/standard/node_modules/eslint/lib/util/xml-escape.js
govuk_publishing_components-17.21.0 node_modules/standard/node_modules/eslint/lib/util/xml-escape.js
govuk_publishing_components-17.20.0 node_modules/standard/node_modules/eslint/lib/util/xml-escape.js
govuk_publishing_components-17.19.1 node_modules/standard/node_modules/eslint/lib/util/xml-escape.js
govuk_publishing_components-17.19.0 node_modules/standard/node_modules/eslint/lib/util/xml-escape.js
govuk_publishing_components-17.18.0 node_modules/standard/node_modules/eslint/lib/util/xml-escape.js
govuk_publishing_components-17.17.0 node_modules/standard/node_modules/eslint/lib/util/xml-escape.js
govuk_publishing_components-17.16.0 node_modules/standard/node_modules/eslint/lib/util/xml-escape.js
govuk_publishing_components-17.15.0 node_modules/standard/node_modules/eslint/lib/util/xml-escape.js
govuk_publishing_components-17.14.0 node_modules/standard/node_modules/eslint/lib/util/xml-escape.js
govuk_publishing_components-17.13.0 node_modules/standard/node_modules/eslint/lib/util/xml-escape.js
govuk_publishing_components-17.12.2 node_modules/standard/node_modules/eslint/lib/util/xml-escape.js
govuk_publishing_components-17.12.1 node_modules/standard/node_modules/eslint/lib/util/xml-escape.js
govuk_publishing_components-17.12.0 node_modules/standard/node_modules/eslint/lib/util/xml-escape.js
govuk_publishing_components-17.11.0 node_modules/standard/node_modules/eslint/lib/util/xml-escape.js
govuk_publishing_components-17.10.0 node_modules/standard/node_modules/eslint/lib/util/xml-escape.js
govuk_publishing_components-17.9.0 node_modules/standard/node_modules/eslint/lib/util/xml-escape.js
govuk_publishing_components-17.8.0 node_modules/standard/node_modules/eslint/lib/util/xml-escape.js
govuk_publishing_components-17.7.0 node_modules/standard/node_modules/eslint/lib/util/xml-escape.js
govuk_publishing_components-17.6.1 node_modules/standard/node_modules/eslint/lib/util/xml-escape.js