From f580bb967ea77cfcaeb03b74c674f14772d5bae0 Mon Sep 17 00:00:00 2001
From: Paul Horn <dev@knutwalker.engineer>
Date: Fri, 29 Sep 2023 17:18:02 +0200
Subject: [PATCH] Allow direct IP uris

---
 lib/src/connection.rs | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lib/src/connection.rs b/lib/src/connection.rs
index e5ba8679..ac148206 100644
--- a/lib/src/connection.rs
+++ b/lib/src/connection.rs
@@ -179,7 +179,9 @@ impl NeoUrl {
         let url = match Url::parse(uri) {
             Ok(url) if url.has_host() => url,
             // missing scheme
-            Ok(_) => Url::parse(&format!("bolt://{}", uri))?,
+            Ok(_) | Err(url::ParseError::RelativeUrlWithoutBase) => {
+                Url::parse(&format!("bolt://{}", uri))?
+            }
             Err(err) => return Err(Error::UrlParseError(err)),
         };
 
@@ -296,4 +298,12 @@ mod tests {
         assert_eq!(url.host(), Host::Domain("localhost"));
         assert_eq!(url.scheme(), "bolt");
     }
+
+    #[test]
+    fn should_parse_ip_uri_without_scheme() {
+        let url = NeoUrl::parse("127.0.0.1:4242").unwrap();
+        assert_eq!(url.port(), 4242);
+        assert_eq!(url.host(), Host::Domain("127.0.0.1"));
+        assert_eq!(url.scheme(), "bolt");
+    }
 }