We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 00f2992 commit 47a800cCopy full SHA for 47a800c
packages/gatsby-source-mongodb/src/gatsby-node.js
@@ -83,7 +83,7 @@ function createNodes(
83
parent: `__${collectionName}__`,
84
children: [],
85
internal: {
86
- type: `mongodb${caps(dbName)}${caps(collectionName)}`,
+ type: `mongodb${sanitizeName(dbName)}${sanitizeName(collectionName)}`,
87
content: JSON.stringify(item),
88
contentDigest: crypto
89
.createHash(`md5`)
@@ -129,8 +129,10 @@ function createNodes(
129
})
130
}
131
132
-function caps(s) {
133
- return s.replace(/\b\w/g, l => l.toUpperCase())
+function sanitizeName(s) {
+ return s
134
+ .replace(/[^_a-zA-Z0-9]/, ``)
135
+ .replace(/\b\w/g, l => l.toUpperCase())
136
137
138
function getConnectionExtraParams(extraParams) {
0 commit comments