Skip to content

Commit f580bb9

Browse files
committed
Allow direct IP uris
1 parent a6840bc commit f580bb9

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/src/connection.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,9 @@ impl NeoUrl {
179179
let url = match Url::parse(uri) {
180180
Ok(url) if url.has_host() => url,
181181
// missing scheme
182-
Ok(_) => Url::parse(&format!("bolt://{}", uri))?,
182+
Ok(_) | Err(url::ParseError::RelativeUrlWithoutBase) => {
183+
Url::parse(&format!("bolt://{}", uri))?
184+
}
183185
Err(err) => return Err(Error::UrlParseError(err)),
184186
};
185187

@@ -296,4 +298,12 @@ mod tests {
296298
assert_eq!(url.host(), Host::Domain("localhost"));
297299
assert_eq!(url.scheme(), "bolt");
298300
}
301+
302+
#[test]
303+
fn should_parse_ip_uri_without_scheme() {
304+
let url = NeoUrl::parse("127.0.0.1:4242").unwrap();
305+
assert_eq!(url.port(), 4242);
306+
assert_eq!(url.host(), Host::Domain("127.0.0.1"));
307+
assert_eq!(url.scheme(), "bolt");
308+
}
299309
}

0 commit comments

Comments
 (0)