-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(gatsby-source-mongodb): sanitize name correctly (#11294)
<!-- Have any questions? Check out the contributing docs at https://gatsby.app/contribute, or ask in this Pull Request and a Gatsby maintainer will be happy to help :) --> ## Description This is the PR for issue #11277. It fixes the sanitizeName error. <!-- Write a brief description of the changes introduced by this PR --> ## Related Issues Related to #11277 <!-- Link to the issue that is fixed by this PR (if there is one) e.g. Fixes #1234, Addresses #1234, Related to #1234, etc. --> Co-authored-by: Dustin Schau <DSchau@users.noreply.github.com> Co-authored-by: Ward Peeters <ward@coding-tech.com>
- Loading branch information
1 parent
5996a6b
commit 731dd60
Showing
3 changed files
with
11 additions
and
4 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
packages/gatsby-source-mongodb/src/__tests__/sanitize-name.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(`-`) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = function sanitizeName(s) { | ||
return s.replace(/[^_a-zA-Z0-9]/g, ``).replace(/\b\w/g, l => l.toUpperCase()) | ||
} |