laodemalfatih/i18next-node-mongo-backend

View on GitHub
libs/sanitizeFieldNameCharacter.js

Summary

Maintainability
A
0 mins
Test Coverage
// Remove MongoDB special character. See https://jira.mongodb.org/browse/SERVER-3229?focusedCommentId=36821&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-36821
const MONGODB_SPECIAL_CHARACTER_REGEX = /^\$|\./g;

module.exports = (fieldName) =>
  fieldName.replace(MONGODB_SPECIAL_CHARACTER_REGEX, '');