Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix env variable names #47

Merged
merged 3 commits into from
Jul 6, 2023
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
7 changes: 6 additions & 1 deletion src/utils/strings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@ describe('toUpperSnakeCase', () => {
assert.equal(result, 'HELLO_WORLD_4');
});

test('trims leading and trailing whtestespaces', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😅

test('trims leading and trailing whitespaces', () => {
const result = toUpperSnakeCase(' hello world ');
assert.equal(result, 'HELLO_WORLD');
});

test('converts special characters to underscores', () => {
const result = toUpperSnakeCase('hello,world!');
assert.equal(result, 'HELLO_WORLD');
});

test('converts special characters and spaces to underscores', () => {
const result = toUpperSnakeCase('hello, world!');
assert.equal(result, 'HELLO_WORLD');
});
Expand Down
4 changes: 2 additions & 2 deletions src/utils/strings.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export function toUpperSnakeCase(input: string): string {
return input
.replace(/[^a-zA-Z0-9\s]+/g, ' ') // replace each non-alphanumeric character with a space
.replace(/\s+/g, ' ') // replace consecutive spaces with a single space
.trim()
.replace(/\s+/g, ' ') // replace multiple spaces with a single space
.replace(/[^a-zA-Z0-9\s]+/g, '') // remove all non-alphanumeric characters
.split(' ')
.join('_')
.toUpperCase();
Expand Down