diff --git a/model/src/main/kotlin/utils/PurlUtils.kt b/model/src/main/kotlin/utils/PurlUtils.kt index 448b922890d07..987ed8609a46e 100644 --- a/model/src/main/kotlin/utils/PurlUtils.kt +++ b/model/src/main/kotlin/utils/PurlUtils.kt @@ -86,12 +86,18 @@ fun Identifier.getPurlType() = * Create the canonical [package URL](https://github.com/package-url/purl-spec) ("purl") based on the properties of * the [Identifier]. Some issues remain with this specification * (see e.g. https://github.com/package-url/purl-spec/issues/33). + * Optional [qualifiers] may be given and will be appended to the purl as query parameters e.g. + * pkg:deb/debian/curl@7.50.3-1?arch=i386&distro=jessie + * Optional [subpath] may be given and will be appended to the purl e.g. + * pkg:golang/google.golang.org/genproto#googleapis/api/annotations * * This implementation uses the package type as 'type' purl element as it is used * [in the documentation](https://github.com/package-url/purl-spec/blob/master/README.rst#purl). * E.g. 'maven' for Gradle projects. */ -fun Identifier.toPurl() = if (this == Identifier.EMPTY) "" else createPurl(getPurlType(), namespace, name, version) +@JvmOverloads +fun Identifier.toPurl(qualifiers: Map = emptyMap(), subpath: String = "") = + if (this == Identifier.EMPTY) "" else createPurl(getPurlType(), namespace, name, version, qualifiers, subpath) /** * Create the canonical [package URL](https://github.com/package-url/purl-spec) ("purl") based on given properties: