Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/gatsby-source-mongodb/src/__tests__/sanitize-name.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const sanitizeName = require(`../sanitize-name`)

it(`removes unsupported characters from name`, () => {
const name = `one-two-three`
const output = sanitizeName(name)
expect(output).not.toContain(`-`)
})
6 changes: 2 additions & 4 deletions packages/gatsby-source-mongodb/src/gatsby-node.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const MongoClient = require(`mongodb`).MongoClient
const crypto = require(`crypto`)
const prepareMappingChildNode = require(`./mapping`)
const sanitizeName = require(`./sanitize-name`)
const _ = require(`lodash`)
Comment thread
harshil1712 marked this conversation as resolved.
Outdated
const queryString = require(`query-string`)

exports.sourceNodes = (
Expand Down Expand Up @@ -130,10 +132,6 @@ function createNodes(
})
}

function sanitizeName(s) {
return s.replace(/[^_a-zA-Z0-9]/, ``).replace(/\b\w/g, l => l.toUpperCase())
}

function getConnectionExtraParams(extraParams) {
let connectionSuffix
if (extraParams) {
Expand Down
5 changes: 5 additions & 0 deletions packages/gatsby-source-mongodb/src/sanitize-name.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = function sanitizeName(s) {
return s.replace(/[^_a-zA-Z0-9]/g, ``).replace(/\b\w/g, l => l.toUpperCase())
}

// module.exports = { sanitizeName }
Comment thread
wardpeet marked this conversation as resolved.
Outdated