chore(): start moving some packages to the core directory (#7215)
This commit is contained in:
committed by
GitHub
parent
fdee748eed
commit
bbccd6481d
@@ -0,0 +1,29 @@
|
||||
type ConnectionStringOptions = {
|
||||
user?: string
|
||||
password?: string
|
||||
host?: string
|
||||
db: string
|
||||
}
|
||||
|
||||
export function encodeDbValue(value: string): string {
|
||||
return encodeURIComponent(value)
|
||||
}
|
||||
|
||||
export default ({ user, password, host, db }: ConnectionStringOptions) => {
|
||||
let connection = `postgres://`
|
||||
if (user) {
|
||||
connection += encodeDbValue(user)
|
||||
}
|
||||
|
||||
if (password) {
|
||||
connection += `:${encodeDbValue(password)}`
|
||||
}
|
||||
|
||||
if (user || password) {
|
||||
connection += "@"
|
||||
}
|
||||
|
||||
connection += `${host}/${db}`
|
||||
|
||||
return connection
|
||||
}
|
||||
Reference in New Issue
Block a user