postgresql-connection-string 0.1.0.5 → 0.1.0.6
raw patch · 3 files changed
+25/−1 lines, 3 files
Files
- postgresql-connection-string.cabal +1/−1
- src/library-tests/Main.hs +19/−0
- src/library/PostgresqlConnectionString/Parsers.hs +5/−0
postgresql-connection-string.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: postgresql-connection-string-version: 0.1.0.5+version: 0.1.0.6 category: Database, PostgreSQL synopsis: PostgreSQL connection string type, parser and builder description:
src/library-tests/Main.hs view
@@ -337,6 +337,25 @@ ConnectionString.toHosts cs `shouldBe` [("localhost", Nothing)] ConnectionString.toUrl cs `shouldBe` "postgresql://user:secret@localhost" + it "postgresql://user:@localhost (empty password)" do+ let input = "postgresql://user:@localhost"+ case ConnectionString.parse input of+ Left err -> expectationFailure ("Parse error: " <> Text.unpack err)+ Right cs -> do+ ConnectionString.toUser cs `shouldBe` Just "user"+ ConnectionString.toPassword cs `shouldBe` Just ""+ ConnectionString.toHosts cs `shouldBe` [("localhost", Nothing)]++ it "postgresql://user:@localhost:5432/mydb (empty password with port and db)" do+ let input = "postgresql://user:@localhost:5432/mydb"+ case ConnectionString.parse input of+ Left err -> expectationFailure ("Parse error: " <> Text.unpack err)+ Right cs -> do+ ConnectionString.toUser cs `shouldBe` Just "user"+ ConnectionString.toPassword cs `shouldBe` Just ""+ ConnectionString.toHosts cs `shouldBe` [("localhost", Just 5432)]+ ConnectionString.toDbname cs `shouldBe` Just "mydb"+ it "postgresql://other@localhost/otherdb?connect_timeout=10&application_name=myapp" do let input = "postgresql://other@localhost/otherdb?connect_timeout=10&application_name=myapp" case ConnectionString.parse input of
src/library/PostgresqlConnectionString/Parsers.hs view
@@ -37,6 +37,11 @@ -- We still don't know if this is user:password@ or host:port asum [ do+ -- Empty password: user:@host+ try (char '@')+ let user = unqualifiedWord+ continueFromHostspec (Just user) (Just "") [],+ do password <- try do label "Password" getWord <* char '@' -- Definitely user:password@ pattern