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

Fix URL parsing without port #50

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Ramkarthik
Copy link

@Ramkarthik Ramkarthik commented Jan 8, 2025

Fixes #49

This is my first PR to this repo, please let me know if I missed anything. I wasn't sure if I should add this to the changelog.

Copy link
Owner

@lpil lpil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lovely work! Thank you! I've left one small note inline, and if you could update the changelog also that would be fab.

src/pog.gleam Outdated
@@ -224,6 +224,10 @@ pub fn default_config() -> Config {
/// Parse a database url into configuration that can be used to start a pool.
pub fn url_config(database_url: String) -> Result(Config, Nil) {
use uri <- result.then(uri.parse(database_url))
let uri = case uri.port {
Some(_) -> uri
None -> Uri(..uri, port: Some(default_config().port))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than building the default config and then accessing the port let's move the default port to a private const and reference that in both places.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I will make this change and update the changelog shortly.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made this change and updated the changelog.

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

Successfully merging this pull request may close these issues.

Url parsing without port doesn't work
2 participants