diff --git a/packages/gatsby/src/schema/__tests__/create-key.js b/packages/gatsby/src/schema/__tests__/create-key.js index da6484dda1888..2de5c7a3915e3 100644 --- a/packages/gatsby/src/schema/__tests__/create-key.js +++ b/packages/gatsby/src/schema/__tests__/create-key.js @@ -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) }) diff --git a/packages/gatsby/src/schema/create-key.js b/packages/gatsby/src/schema/create-key.js index 4cb78499f5552..ab54c3828f5b0 100644 --- a/packages/gatsby/src/schema/create-key.js +++ b/packages/gatsby/src/schema/create-key.js @@ -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