Skip to content

Commit f17f17d

Browse files
committed
🐛 Use URL instead of regex for shadow-db name
connectionString is a URL, so it should be treated as such. regex didn't handle more complex cases (such as "-" in the name of database). And while it is possible to tweak regex for greater compatibility, using actual URL-object guarantees proper result in ALL cases. #434
1 parent 1840012 commit f17f17d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/migrator/src/migrator.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,11 @@ export class Migrator {
728728
*/
729729
async useShadowClient<T>(cb: (client: Client) => Promise<T>) {
730730
const shadowDbName = `shadow_${Date.now()}_${randomInt(1_000_000)}`
731-
const shadowConnectionString = this.client.connectionString().replace(/\w+$/, shadowDbName)
731+
732+
const shadowConnectionUrl = new URL(this.client.connectionString());
733+
shadowConnectionUrl.pathname = shadowDbName;
734+
const shadowConnectionString = shadowConnectionUrl.toString();
735+
732736
const shadowClient = createClient(shadowConnectionString, this.client.options)
733737

734738
try {

0 commit comments

Comments
 (0)