Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pg-connection-string parser does not work on the browser #3126

Open
tmadeira opened this issue Jan 12, 2024 · 3 comments
Open

pg-connection-string parser does not work on the browser #3126

tmadeira opened this issue Jan 12, 2024 · 3 comments

Comments

@tmadeira
Copy link

f305419 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:

2024-01-12_14:41:09

The failure happens because it seems to only support some specific protocols -- if I replace postgresql with ftp, I get the correctly parsing:

2024-01-12_14:42:06

@charmander
Copy link
Collaborator

What will you use pg-connection-string for on the browser?

@tmadeira
Copy link
Author

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

@hjr3
Copy link
Contributor

hjr3 commented Jan 17, 2024

Related to #3032

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants