diff --git a/crates/distribution-types/src/direct_url.rs b/crates/distribution-types/src/direct_url.rs index a25a6160c..75e29c31f 100644 --- a/crates/distribution-types/src/direct_url.rs +++ b/crates/distribution-types/src/direct_url.rs @@ -130,7 +130,7 @@ impl TryFrom<&LocalFileUrl> for pypi_types::DirectUrl { fn try_from(value: &LocalFileUrl) -> Result { Ok(pypi_types::DirectUrl::LocalDirectory { - url: value.url.to_string(), + url: value.url.clone(), dir_info: pypi_types::DirInfo { editable: None }, }) } @@ -141,7 +141,7 @@ impl TryFrom<&DirectArchiveUrl> for pypi_types::DirectUrl { fn try_from(value: &DirectArchiveUrl) -> Result { Ok(pypi_types::DirectUrl::ArchiveUrl { - url: value.url.to_string(), + url: value.url.clone(), archive_info: pypi_types::ArchiveInfo { hash: None, hashes: None, @@ -156,7 +156,7 @@ impl TryFrom<&DirectGitUrl> for pypi_types::DirectUrl { fn try_from(value: &DirectGitUrl) -> Result { Ok(pypi_types::DirectUrl::VcsUrl { - url: value.url.repository().to_string(), + url: value.url.repository().clone(), vcs_info: pypi_types::VcsInfo { vcs: pypi_types::VcsKind::Git, commit_id: value.url.precise().as_ref().map(ToString::to_string), diff --git a/crates/pypi-types/src/direct_url.rs b/crates/pypi-types/src/direct_url.rs index 3a33269f2..a1881d0fc 100644 --- a/crates/pypi-types/src/direct_url.rs +++ b/crates/pypi-types/src/direct_url.rs @@ -2,6 +2,7 @@ use std::collections::HashMap; use std::path::PathBuf; use serde::{Deserialize, Serialize}; +use url::Url; /// Metadata for a distribution that was installed via a direct URL. /// @@ -13,13 +14,13 @@ pub enum DirectUrl { /// ```json /// {"url": "file:///home/user/project", "dir_info": {}} /// ``` - LocalDirectory { url: String, dir_info: DirInfo }, + LocalDirectory { url: Url, dir_info: DirInfo }, /// The direct URL is a path to an archive. For example: /// ```json /// {"archive_info": {"hash": "sha256=75909db2664838d015e3d9139004ee16711748a52c8f336b52882266540215d8", "hashes": {"sha256": "75909db2664838d015e3d9139004ee16711748a52c8f336b52882266540215d8"}}, "url": "https://files.pythonhosted.org/packages/b8/8b/31273bf66016be6ad22bb7345c37ff350276cfd46e389a0c2ac5da9d9073/wheel-0.41.2-py3-none-any.whl"} /// ``` ArchiveUrl { - url: String, + url: Url, archive_info: ArchiveInfo, #[serde(skip_serializing_if = "Option::is_none")] subdirectory: Option, @@ -29,7 +30,7 @@ pub enum DirectUrl { /// {"url": "https://github.com/pallets/flask.git", "vcs_info": {"commit_id": "8d9519df093864ff90ca446d4af2dc8facd3c542", "vcs": "git"}} /// ``` VcsUrl { - url: String, + url: Url, vcs_info: VcsInfo, #[serde(skip_serializing_if = "Option::is_none")] subdirectory: Option,