From 0fd2433be9203b58e5783fee49261fed921f3948 Mon Sep 17 00:00:00 2001 From: Jacob Baker-Kretzmar Date: Wed, 26 Jun 2024 12:06:58 -0400 Subject: [PATCH] Fix truncating database name --- src/lib.ts | 2 +- tests/unit/lib.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.ts b/src/lib.ts index e7c5f46..91f190a 100644 --- a/src/lib.ts +++ b/src/lib.ts @@ -22,7 +22,7 @@ export function tap(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(); } diff --git a/tests/unit/lib.test.ts b/tests/unit/lib.test.ts index 1c33989..10b59cd 100644 --- a/tests/unit/lib.test.ts +++ b/tests/unit/lib.test.ts @@ -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);