Skip to content

Commit

Permalink
Merge pull request #41 from bakerkretzmar/fix-db-name
Browse files Browse the repository at this point in the history
Fix truncating database name
  • Loading branch information
bakerkretzmar authored Jun 26, 2024
2 parents c04e092 + 0fd2433 commit cd4cf8c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function tap<T>(value: any, interceptor: (v: any) => T) {
export function normalizeDatabaseName(input: string) {
return input
.replace(/[\W_]+/g, '_')
.substring(0, 64)
.substring(0, 63)
.replace(/^_|_$/g, '')
.toLowerCase();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/lib.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('normalizeDatabaseName', () => {
['one! two? three 0x995', 'one_two_three_0x995'],
['jbk/px-454', 'jbk_px_454'],
["please+don't %20 do / this", 'please_don_t_20_do_this'],
['a'.repeat(65), 'a'.repeat(64)],
['a'.repeat(65), 'a'.repeat(63)],
['FOO bar', 'foo_bar'],
])('%s → %s', (input, output) => {
expect(normalizeDatabaseName(input)).toBe(output);
Expand Down

0 comments on commit cd4cf8c

Please sign in to comment.