diff --git a/CHANGELOG.md b/CHANGELOG.md index df208cb..bf49357 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [UNRELEASED] +### Fixed + +- Handle case where parse fails on invalid port ([#50](https://github.com/tjtelan/git-url-parse-rs/issues/50)) + +## [0.4.3](https://github.com/tjtelan/git-url-parse-rs/tree/v0.4.3) - 2022-10-11 + ### Added - Add short git URL notation support ([#28](https://github.com/tjtelan/git-url-parse-rs/issues/28)) diff --git a/Cargo.toml b/Cargo.toml index 1354e78..4b6c907 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT" name = "git-url-parse" readme = "README.md" repository = "https://github.com/tjtelan/git-url-parse-rs" -version = "0.4.3" +version = "0.4.4" [dependencies] tracing = "0.1" diff --git a/src/lib.rs b/src/lib.rs index 60f7bc0..cad821d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -388,8 +388,7 @@ pub fn normalize_url(url: &str) -> Result { } } } - Err(_e) => { - // e will most likely be url::ParseError::RelativeUrlWithoutBase + Err(url::ParseError::RelativeUrlWithoutBase) => { // If we're here, we're only looking for Scheme::Ssh or Scheme::File // Assuming we have found Scheme::Ssh if we can find an "@" before ":" @@ -411,5 +410,8 @@ pub fn normalize_url(url: &str) -> Result { } } } + Err(err) => { + return Err(eyre!("url parsing failed: {:?}", err)); + } }) } diff --git a/tests/parse.rs b/tests/parse.rs index a30306f..4bc55a4 100644 --- a/tests/parse.rs +++ b/tests/parse.rs @@ -367,6 +367,18 @@ fn ssh_without_organization() { assert_eq!(parsed, expected); } +#[test] +fn bad_port_number() { + let test_url = "https://github.com:crypto-browserify/browserify-rsa.git"; + let e = GitUrl::parse(test_url); + + assert!(e.is_err()); + assert_eq!( + format!("{}", e.err().unwrap()), + "Url normalization into url::Url failed" + ); +} + #[test] fn git() { let test_url = "git:github.com/owner/name.git";