diff --git a/src/shared/prompts/functions.ts b/src/shared/prompts/functions.ts index 071caa42..b39205bd 100644 --- a/src/shared/prompts/functions.ts +++ b/src/shared/prompts/functions.ts @@ -13,7 +13,7 @@ import { messages } from './nameField.js'; * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ export const makeNameApiCompatible = (input: string): string => - input.replace(/ /g, '').replace(/-/g, '_').replace(/_{2,}/g, '_'); + input.replace(/ /g, '_').replace(/-/g, '_').replace(/_{2,}/g, '_'); export const integerValidation = ({ min, max }: { min: number; max: number }) => diff --git a/test/shared/prompts.test.ts b/test/shared/prompts.test.ts index 2140f245..6bac46f8 100644 --- a/test/shared/prompts.test.ts +++ b/test/shared/prompts.test.ts @@ -32,8 +32,8 @@ describe('integer validation for prompts', () => { describe('api name compatibility', () => { it('handles spaces', () => { - expect(makeNameApiCompatible('foo bar')).to.equal('foobar'); - expect(makeNameApiCompatible('foo bar')).to.equal('foobar'); + expect(makeNameApiCompatible('foo bar')).to.equal('foo_bar'); + expect(makeNameApiCompatible('foo bar')).to.equal('foo_bar'); }); it('handles hyphens', () => { expect(makeNameApiCompatible('foo-bar')).to.equal('foo_bar');