Skip to content

Add Url (net) #46

@vhrcgcom

Description

@vhrcgcom

Description

Implement Url as a ValueObject in the net module.

Spec: valid URL, wraps url crate

Implementation checklist

  • Create src/net/url.rs
  • Implement ValueObject trait
  • Add #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
  • Export from src/net/mod.rs and prelude
  • Unit tests: valid input · empty input · invalid format · normalisation
  • Doc comment with # Example block
  • Update status in ROADMAP.md from ⬜ to ✅

Implementation detail

Input / Output

Type Alias
Input String UrlInput
Output String — normalised by the url crate UrlOutput

Normalization

Parse with url::Url; the crate normalises scheme and host to lowercase and canonicalises the path.

Validation

Must be parseable as a URL by the url crate. Any scheme is accepted (unlike Website, which restricts to http/https). A host is required.

Notes

Uses the url crate already present as an optional dependency (dep:url). No new dependencies needed.

Extra methods

  • scheme() -> &str — e.g. "https".
  • host() -> Option<&str> — the hostname, if present.
  • path() -> &str — the path component, e.g. "/api/v1".

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions