Skip to content

Commit

Permalink
fix: replace spaces with underscores for api name
Browse files Browse the repository at this point in the history
  • Loading branch information
k-capehart committed Oct 17, 2024
1 parent 8a78e8c commit e98ac0e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/shared/prompts/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) =>
Expand Down
4 changes: 2 additions & 2 deletions test/shared/prompts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit e98ac0e

Please sign in to comment.