UNPKG

yoastseo

Version:

Yoast client-side content analysis

29 lines (27 loc) 1.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = _default; /** @module stringProcessing/stripSpaces */ /** * Replaces multiple spaces with a single space. * Removes spaces followed by a period (if there's no text after the period) and spaces in the beginning or end of a string. * * @param {String} text The text to strip spaces from. * @returns {String} The text with stripped spaces. */ function _default(text) { // Replaces multiple spaces with a single space. text = text.replace(/\s{2,}/g, " "); // Replaces space(s) followed by a period, if the period is the last character, with only the period. text = text.replace(/\s\.$/, "."); // Removes first/last character if it's a space. text = text.replace(/^\s+|\s+$/g, ""); // Replaces spaces followed by a Japanese period with only the period. text = text.replace(/\s。/g, "。"); // Replaces spaces after a Japanese period with only the period. text = text.replace(/。\s/g, "。"); return text; } //# sourceMappingURL=stripSpaces.js.map