Skip to content

Commit d6c59f0

Browse files
tgagneret-embeddedkartben
authored andcommitted
scripts: zephyr_module: Fix purl regex
Remove root domain from PURL type Nested PURL namespaces were not correctly detected. Signed-off-by: Thomas Gagneret <thomas.gagneret@hexploy.com>
1 parent cc6eaa0 commit d6c59f0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

scripts/west_commands/zspdx/walker.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ def _build_purl(self, url, version=None):
7777

7878
purl = None
7979
# This is designed to match repository with the following url pattern:
80-
# '<protocol><base_url>/<namespace>/<package>
81-
COMMON_GIT_URL_REGEX=r'((git@|http(s)?:\/\/)(?P<base_url>[\w\.@]+)(\/|:))(?P<namespace>[\w,\-,\_]+)\/(?P<package>[\w,\-,\_]+)(.git){0,1}((\/){0,1})$'
80+
# '<protocol><type>/<namespace>/<package>
81+
COMMON_GIT_URL_REGEX=r'((git@|http(s)?:\/\/)(?P<type>[\w\.@]+)(\.\w+)(\/|:))(?P<namespace>[\w,\-,\_\/]+)\/(?P<package>[\w,\-,\_]+)(.git){0,1}((\/){0,1})$'
8282

8383
match = re.fullmatch(COMMON_GIT_URL_REGEX, url)
8484
if match:
85-
purl = f'pkg:{match.group("base_url")}/{match.group("namespace")}/{match.group("package")}'
85+
purl = f'pkg:{match.group("type")}/{match.group("namespace")}/{match.group("package")}'
8686

8787
if purl and (version or len(version) > 0):
8888
purl += f'@{version}'

0 commit comments

Comments
 (0)