Skip to content

Commit

Permalink
feat: allow clearing namespace, version, sub path, and qualifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
ctron committed May 27, 2024
1 parent e2cbf53 commit 9d39f9c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/purl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ impl<'a> PackageUrl<'a> {
self
}

/// Clear the namespace
pub fn without_namespace(&mut self) -> &mut Self {
self.namespace = None;
self
}

/// Assign a version to the package.
pub fn with_version<V>(&mut self, version: V) -> &mut Self
where
Expand All @@ -184,6 +190,12 @@ impl<'a> PackageUrl<'a> {
self
}

/// Clear the version
pub fn without_version(&mut self) -> &mut Self {
self.version = None;
self
}

/// Assign a subpath to the package.
///
/// Subpaths must not contain empty, local ('.') or parent ('..') segments,
Expand All @@ -202,6 +214,18 @@ impl<'a> PackageUrl<'a> {
Ok(self)
}

/// Clear the subpath
pub fn without_subpath(&mut self) -> &mut Self {
self.subpath = None;
self
}

/// Clear qualifiers
pub fn clear_qualifiers(&mut self) -> &mut Self {
self.qualifiers.clear();
self
}

/// Add a qualifier to the package.
pub fn add_qualifier<K, V>(&mut self, key: K, value: V) -> Result<&mut Self>
where
Expand Down

0 comments on commit 9d39f9c

Please sign in to comment.