lamualfa/dn-i18next-mongo-backend

View on GitHub
lib/sanitizer.ts

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;

export function sanitizeMongoDbFieldName(fieldName: string): string {
  return fieldName.replace(MONGODB_SPECIAL_CHARACTER_REGEX, '');
}