Skip to content

Commit 94db98c

Browse files
committed
Refine the purl_from_pattern function to handle unwanted matched fields
Signed-off-by: Thomas Druez <tdruez@nexb.com>
1 parent cf114f7 commit 94db98c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/packageurl/contrib/url2purl.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ def purl_from_pattern(type_, pattern, uri):
7575
match = compiled_pattern.match(uri)
7676

7777
if match:
78-
return PackageURL(type_, **match.groupdict())
78+
purl_data = {
79+
field: value for field, value in match.groupdict().items()
80+
if field in PackageURL._fields
81+
}
82+
return PackageURL(type_, **purl_data)
7983

8084

8185
@purl_router.route('https?://registry.npmjs.*/.*',

0 commit comments

Comments
 (0)