-
-
Notifications
You must be signed in to change notification settings - Fork 376
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Summary 💡
Right now it is not possible to manipulate a gix_url::Url
easily. I propose a small addition to the API to allow e.g. transforming the path of a URL.
let url = gix_url::url::parse("https://github.com/samvv/mage").unwrap();
let new_url = url.map_path(|p| format!("{}.git").into());
println!("{}", new_url); // outputs https://github.com/samvv/mage.git
Note that a bformat
(a format!
for BString) would make this even easier and also less buggy, but such a macro doesn't exist.
Alternatively, one could provide a group of setters to manipulate a URL:
let url = gix_url::url::parse("https://github.com/samvv/mage").unwrap();
url.set_path(format!("{}.git", url.path).into());
println!("{}", url); // outputs https://github.com/samvv/mage.git
Or maybe a builder pattern:
let new_url = gix_url::Url::build()
.schema(url.schema)
.user(url.user())
.password(url.password())
.host(url.host())
.path(format!("{}.git", url.path).into());
Motivation 🔦
I'm writing a build system for Linux packages and need to transform a raw repo URL (e.g. https://github.com/samvv/mage
) to its Git URL (e.g. https://github.com/samvv/mage.git
), just like NPM does.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request