Sha256: dfe0dfc63785f4c4b656e95087b70252a15ef80f5c1b087df9756a741dda7f27

Contents?: true

Size: 1.63 KB

Versions: 8

Compression:

Stored size: 1.63 KB

Contents

const z = (() => {
  // https://github.com/lodash/lodash/blob/master/escape.js

  /** Used to map characters to HTML entities. */
  const htmlEscapes = {
    '&': '&',
    '<': '&lt;',
    '>': '&gt;',
    '"': '&quot;',
    "'": '&#39;'
  }

  /** Used to match HTML entities and HTML characters. */
  const reUnescapedHtml = /[&<>"']/g
  const reHasUnescapedHtml = RegExp(reUnescapedHtml.source)

  /**
   * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
   * corresponding HTML entities.
   *
   * **Note:** No other characters are escaped. To escape additional
   * characters use a third-party library like [_he_](https://mths.be/he).
   *
   * Though the ">" character is escaped for symmetry, characters like
   * ">" and "/" don't need escaping in HTML and have no special meaning
   * unless they're part of a tag or unquoted attribute value. See
   * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
   * (under "semi-related fun fact") for more details.
   *
   * When working with HTML you should always
   * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
   * XSS vectors.
   *
   * @since 0.1.0
   * @category String
   * @param {string} [string=''] The string to escape.
   * @returns {string} Returns the escaped string.
   * @see escapeRegExp, unescape
   * @example
   *
   * escape('fred, barney, & pebbles')
   * // => 'fred, barney, &amp; pebbles'
   */
  function escape(string) {
    return (string && reHasUnescapedHtml.test(string))
      ? string.replace(reUnescapedHtml, (chr) => htmlEscapes[chr])
      : (string || '')
  }

  return { escape }
})();

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
zuora_connect_ui-0.10.3 app/assets/javascripts/zuora_connect_ui/util.js
zuora_connect_ui-0.10.2 app/assets/javascripts/zuora_connect_ui/util.js
zuora_connect_ui-0.10.1 app/assets/javascripts/zuora_connect_ui/util.js
zuora_connect_ui-0.10.0 app/assets/javascripts/zuora_connect_ui/util.js
zuora_connect_ui-0.9.2 app/assets/javascripts/zuora_connect_ui/util.js
zuora_connect_ui-0.9.1 app/assets/javascripts/zuora_connect_ui/util.js
zuora_connect_ui-0.9.0 app/assets/javascripts/zuora_connect_ui/util.js
zuora_connect_ui-0.8.3 app/assets/javascripts/zuora_connect_ui/util.js