Sha256: e4a5dc1a81e31aa4830192a90a09dc8f760405f760f03d4280980cf6af4e8c75

Contents?: true

Size: 435 Bytes

Versions: 375

Compression:

Stored size: 435 Bytes

Contents

/* global text */

/**
 * Removes carriage returns, newline characters, tabs, non-breaking spaces, and trailing spaces from string
 * @method sanitize
 * @memberof axe.commons.text
 * @instance
 * @param  {String} str String to be cleaned
 * @return {String} Sanitized string
 */
text.sanitize = function(str) {
	'use strict';
	return str
		.replace(/\r\n/g, '\n')
		.replace(/\u00A0/g, ' ')
		.replace(/[\s]{2,}/g, ' ')
		.trim();
};

Version data entries

375 entries across 375 versions & 1 rubygems

Version Path
govuk_publishing_components-25.3.0 node_modules/axe-core/lib/commons/text/sanitize.js
govuk_publishing_components-25.2.3 node_modules/axe-core/lib/commons/text/sanitize.js
govuk_publishing_components-25.2.2 node_modules/axe-core/lib/commons/text/sanitize.js
govuk_publishing_components-25.2.1 node_modules/axe-core/lib/commons/text/sanitize.js
govuk_publishing_components-25.2.0 node_modules/axe-core/lib/commons/text/sanitize.js
govuk_publishing_components-25.1.0 node_modules/axe-core/lib/commons/text/sanitize.js
govuk_publishing_components-25.0.0 node_modules/axe-core/lib/commons/text/sanitize.js
govuk_publishing_components-24.21.1 node_modules/axe-core/lib/commons/text/sanitize.js
govuk_publishing_components-24.21.0 node_modules/axe-core/lib/commons/text/sanitize.js
govuk_publishing_components-24.20.0 node_modules/axe-core/lib/commons/text/sanitize.js
govuk_publishing_components-24.19.0 node_modules/axe-core/lib/commons/text/sanitize.js
govuk_publishing_components-24.18.5 node_modules/axe-core/lib/commons/text/sanitize.js
govuk_publishing_components-24.18.4 node_modules/axe-core/lib/commons/text/sanitize.js
govuk_publishing_components-24.18.3 node_modules/axe-core/lib/commons/text/sanitize.js
govuk_publishing_components-24.18.2 node_modules/axe-core/lib/commons/text/sanitize.js
govuk_publishing_components-24.18.1 node_modules/axe-core/lib/commons/text/sanitize.js
govuk_publishing_components-24.18.0 node_modules/axe-core/lib/commons/text/sanitize.js
govuk_publishing_components-24.17.0 node_modules/axe-core/lib/commons/text/sanitize.js
govuk_publishing_components-24.16.1 node_modules/axe-core/lib/commons/text/sanitize.js
govuk_publishing_components-24.16.0 node_modules/axe-core/lib/commons/text/sanitize.js