Skip to main content

Converts invalid characters to dashes according to http://www.w3.org/TR/REC-xml/#NT-Name.

/**
 * Convert invalid characters to dashes.
 * http://www.w3.org/TR/REC-xml/#NT-Name
 *
 * @param {String} key The key to clean.
 * @return {String} The cleaned key.
 */
function cleanKey(key) {
    return key.replace(/[^-._0-9A-Za-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u37f-\u1fff\u200c-\u200d\u203f\u2040\u2070-\u218f]/g, "-");
}