read_url/git/
context.rs

1use super::{
2    super::{context::*, errors::*, url::*},
3    errors::*,
4    git_url::*,
5};
6
7use relative_path::*;
8
9impl UrlContext {
10    /// Construct a [GitUrl].
11    pub fn git_url(
12        self: &UrlContextRef,
13        conformed_repository_url: UrlRef,
14        path: RelativePathBuf,
15    ) -> Result<UrlRef, UrlError> {
16        // Note: gix will strip the query and fragment, which is why we are also keeping the original URL
17        let repository_gix_url =
18            gix::Url::from_bytes(conformed_repository_url.to_string().as_bytes().into()).map_err(GitError::from)?;
19
20        Ok(GitUrl::new(self, conformed_repository_url.into(), repository_gix_url, path).into())
21    }
22}