Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions packages/gatsby/src/schema/__tests__/create-key.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ describe(`createKey`, () => {
it(`replaces invalid characters`, () => {
;[
[`/hello`, `_hello`],
[`~/path/to/some/module`, `_-path-to-some-module`],
[`/*`, `_-`],
[`/*.js`, `_--js`],
[`~/path/to/some/module`, `_xpathxtoxsomexmodule`],
[`/*`, `_x`],
[`/*.js`, `_xxjs`],
].forEach(([input, output]) => {
expect(createKey(input)).toBe(output)
})
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby/src/schema/create-key.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ module.exports = (key: string): string => {

const replaced = key.replace(nonAlphaNumericExpr, `_`)

// key is invalid; normalize with a leading underscore and dasherize rest
// key is invalid; normalize with leading underscore and rest with x
if (replaced.match(/^__/)) {
return replaced.replace(/_/g, (char, index) => (index === 0 ? `_` : `-`))
return replaced.replace(/_/g, (char, index) => (index === 0 ? `_` : `x`))
}

return replaced
Expand Down