Skip to content

Commit

Permalink
Merge pull request #33 from bakerkretzmar/lowercase-domains
Browse files Browse the repository at this point in the history
Lowercase domain and database names
  • Loading branch information
bakerkretzmar authored Nov 17, 2023
2 parents 15a17c9 + 30b8120 commit 93a7609
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ export function normalizeDatabaseName(input: string) {
return input
.replace(/[\W_]+/g, '_')
.substring(0, 64)
.replace(/^_|_$/g, '');
.replace(/^_|_$/g, '')
.toLowerCase();
}

export function normalizeDomainName(input: string) {
return input.replace(/\W+/g, '-').substring(0, 63).replace(/^-|-$/g, '');
return input.replace(/\W+/g, '-').substring(0, 63).replace(/^-|-$/g, '').toLowerCase();
}

export function updateDotEnvString(env: string, variables: Record<string, string | undefined>) {
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/lib.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ describe('normalizeDatabaseName', () => {
['jbk/px-454', 'jbk_px_454'],
["please+don't %20 do / this", 'please_don_t_20_do_this'],
['a'.repeat(65), 'a'.repeat(64)],
['FOO bar', 'foo_bar'],
])('%s → %s', (input, output) => {
expect(normalizeDatabaseName(input)).toBe(output);
});
Expand All @@ -74,6 +75,7 @@ describe('normalizeDomainName', () => {
['jbk/px-454', 'jbk-px-454'],
["please+don't %20 do / this", 'please-don-t-20-do-this'],
['a'.repeat(65), 'a'.repeat(63)],
['FOO bar', 'foo-bar'],
])('%s → %s', (input, output) => {
expect(normalizeDomainName(input)).toBe(output);
});
Expand Down

0 comments on commit 93a7609

Please sign in to comment.