Add HTTPS/domain support via url crate, bump edition/version, add CI and tests#4
Conversation
💡 Codex ReviewLines 318 to 319 in 862b02c Switching ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
| #[test] | ||
| fn parse_link_accepts_uppercase_https() { | ||
| let link: Link = "HTTPS://EXAMPLE.COM/a/b".parse().expect("link"); | ||
| assert_eq!(link.to_string(), "https://example.com/a/b"); | ||
| } | ||
|
|
||
| #[test] | ||
| fn parse_link_accepts_ipv6_host() { | ||
| let link: Link = "https://[::1]:443/a/b".parse().expect("link"); | ||
| assert_eq!(link.to_string(), "https://[::1]:443/a/b"); | ||
| } | ||
|
|
||
| #[test] | ||
| fn parse_link_rejects_unsupported_protocol() { | ||
| let err = "ftp://example.com/a" | ||
| .parse::<Link>() | ||
| .expect_err("unsupported protocol should fail"); | ||
| assert!(err.to_string().contains("invalid protocol")); | ||
| } | ||
|
|
There was a problem hiding this comment.
It seems we are missing edge case test here. if we try parse link from "https://example.com". Result link via to_string() will produce "https://example.com/" with / at the end. Because url crate sets the PathBuf to root /. Is it expected behaviour?
Motivation
Description
.github/workflows/ci.ymlto runcargo testacross a feature matrix including--no-default-features, default,--all-features, and individual featureshash,stream,serialize, anduuid.urlcrate by introducinguse url::Url;and parsingHostfrom aUrl::parseresult, and added rejection checks for userinfo, query, fragment, and unexpected path components.Protocol::HTTPSandAddress::Domain(String)variants and updated ordering,as_ip,is_localhost, andGetSizeimplementations accordingly.versionto0.5.0,editionto2024, updated dependency versions (includingdestream = "0.10",hr-id = "0.7", addedurl = "2.5") and addedserde_jsonin[dev-dependencies].src/lib.rs, serde roundtrip tests insrc/serial.rs, and destream trait presence tests insrc/stream.rs, and a minor import reordering insrc/path.rs.Testing
src/lib.rs,src/serial.rs, andsrc/stream.rsand ran the test suite withcargo test, and all tests passed locally.cargo test ${{ matrix.args }}for multiple feature combinations so the same unit tests will be executed automatically on push and pull requests.Codex Task