Open tmadeira opened 9 months ago
What will you use pg-connection-string for on the browser?
What will you use pg-connection-string for on the browser?
@charmander, we currently use it to parse a connection string in the UI of an app/website builder (https://plasmic.app/).
Code (with a workaround replacing [protocol]://
with ftp://
to work on the browser): https://github.com/plasmicapp/plasmic/blob/dff591aa037cb1f20fde216df9c6b4a55d2f5883/platform/wab/src/wab/client/components/modals/DataSourceModal.tsx#L866
Video demonstrating usage: https://github.com/brianc/node-postgres/assets/3820/508eeff8-659f-474b-b3fc-b0ed97de7f8f
https://github.com/brianc/node-postgres/commit/f305419676afe79a91dc7863289f7f97ac6db3d5 made it possible to import and use
pg-connection-string
on the browser; however, the parser does not work correctly.On the browser,
parse("postgres://user:pass@host:123/base")
is currently returning{user: '', password: '', host: '', port: '', database: '/user:pass@host:123/base'}
.That is happening because of the difference between the URL constructor on node vs. browser. At least on Chrome (I'm on Chromium 120.0.6099.217, to be specific),
new URL("postgres://user:pass@host:123/base")
is not properly parsed:The failure happens because it seems to only support some specific protocols -- if I replace
postgresql
withftp
, I get the correctly parsing: