import * as pulumi from "@pulumi/pulumi" ; export function parseConnString ( conns ) { function toBase64 ( s ) { return Buffer . from ( s ) . toString ( "base64" ) ; } return conns . apply ( conns => { const conn = conns [ 0 ] ; const noProtocol = conn . replace ( /^mongodb\:\/\// , "" ) ; const [ username , rest1 , rest2 ] = noProtocol . split ( ":" , 3 ) ; const [ password , host ] = rest1 . split ( "@" , 2 ) ; const [ port , rest3 ] = rest2 . split ( "/" , 2 ) ; const database = rest3 . replace ( /\?ssl=true$/ , "" ) ; return { host : toBase64 ( host ) , port : toBase64 ( port ) , username : toBase64 ( username ) , password : toBase64 ( encodeURIComponent ( password ) ) , database : toBase64 ( database === "" ? "test" : database ) , } ; } ) ; }