Skip to content

Commit 642d463

Browse files
committed
feat: allow db urls to only start and not be equal to DATABASE_URL
1 parent 1af17ac commit 642d463

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/utils/getDbConnections.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,16 @@ export function getDbConnectionsFromEnv(): Map<string, string> {
1212

1313
if (trimmedLine.startsWith("#")) {
1414
currentComment = trimmedLine.slice(1).trim();
15-
} else if (trimmedLine.startsWith("DATABASE_URL")) {
15+
} else if (/^DATABASE_URL[_=]/.test(trimmedLine)) {
1616
const [key, value] = trimmedLine.split("=").map((part) => part.trim());
17-
dbConnections.set(currentComment || key, value);
17+
let identifier = currentComment;
18+
if (currentComment === "") {
19+
identifier =
20+
key.split("_").slice(2).join("_").toLowerCase() || "unknown";
21+
}
22+
dbConnections.set(identifier, value);
23+
currentComment = "";
1824
}
1925
}
20-
2126
return dbConnections;
2227
}

0 commit comments

Comments
 (0)