yoastseo
Version:
Yoast client-side content analysis
65 lines (61 loc) • 2.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.stripWordBoundariesStart = exports.stripWordBoundariesEverywhere = exports.stripWordBoundariesEnd = exports.default = void 0;
/*
* \u00a0 - No-break space
* \u06d4 - Urdu full stop
* \u061f - Arabic question mark
* \u060C - Arabic comma
* \u061B - Arabic semicolon
*/
const wordBoundary = "[ \\u00a0\\u06d4\\u061f\\u060C\\u061B \\n\\r\\t.,'()\"+\\-;!?:/»«‹›<>]";
const wordBoundaryStart = new RegExp("^(" + wordBoundary + "+)", "ig");
const wordBoundaryEnd = new RegExp("(" + wordBoundary + "+$)", "ig");
/**
* Strip word boundary markers from text in the beginning
*
* @param {String} text The text to strip word boundary markers from.
*
* @returns {String} The text without double word boundary markers.
*/
const stripWordBoundariesStart = function (text) {
// Remove first character if word boundary
text = text.replace(wordBoundaryStart, "");
return text;
};
/**
* Strip word boundary markers from text in the end
*
* @param {String} text The text to strip word boundary markers from.
*
* @returns {String} The text without double word boundary markers.
*/
exports.stripWordBoundariesStart = stripWordBoundariesStart;
const stripWordBoundariesEnd = function (text) {
// Remove last character if word boundary
text = text.replace(wordBoundaryEnd, "");
return text;
};
/**
* Strip word boundary markers from text in the beginning and in the end
*
* @param {String} text The text to strip word boundary markers from.
*
* @returns {String} The text without word boundary markers.
*/
exports.stripWordBoundariesEnd = stripWordBoundariesEnd;
const stripWordBoundariesEverywhere = function (text) {
// Remove first/last character if word boundary
text = text.replace(wordBoundaryStart, "");
text = text.replace(wordBoundaryEnd, "");
return text;
};
exports.stripWordBoundariesEverywhere = stripWordBoundariesEverywhere;
var _default = exports.default = {
stripWordBoundariesStart: stripWordBoundariesStart,
stripWordBoundariesEnd: stripWordBoundariesEnd,
stripWordBoundariesEverywhere: stripWordBoundariesEverywhere
};
//# sourceMappingURL=stripWordBoundaries.js.map