Skip to content

Commit c50992f

Browse files
committed
Extend URL heuristics: extended existing label map coverage and added url map to reflect PyPI heuristics
1 parent ea226c4 commit c50992f

File tree

1 file changed

+42
-2
lines changed
  • cyclonedx_py/_internal/utils

1 file changed

+42
-2
lines changed

cyclonedx_py/_internal/utils/cdx.py

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"""
2020
CycloneDX related helpers and utils.
2121
"""
22-
22+
from urllib.parse import urlparse
2323
from collections.abc import Iterable
2424
from re import compile as re_compile
2525
from typing import Any, Optional
@@ -134,12 +134,52 @@ def licenses_fixup(component: 'Component') -> None:
134134
'docs': ExternalReferenceType.DOCUMENTATION,
135135
'changelog': ExternalReferenceType.RELEASE_NOTES,
136136
'changes': ExternalReferenceType.RELEASE_NOTES,
137+
'releasenotes': ExternalReferenceType.RELEASE_NOTES,
138+
'news': ExternalReferenceType.RELEASE_NOTES,
139+
'whatsnew': ExternalReferenceType.RELEASE_NOTES,
140+
'history': ExternalReferenceType.RELEASE_NOTES,
137141
# 'source': ExternalReferenceType.SOURCE-DISTRIBUTION,
138142
'repository': ExternalReferenceType.VCS,
139143
'github': ExternalReferenceType.VCS,
140144
'chat': ExternalReferenceType.CHAT,
145+
'sponsor': ExternalReferenceType.SOCIAL,
146+
'donation': ExternalReferenceType.SOCIAL,
147+
'donate': ExternalReferenceType.SOCIAL
148+
}
149+
URL_MAP = {
150+
# Hosting
151+
"github.com": ExternalReferenceType.VCS,
152+
"gitlab.com": ExternalReferenceType.VCS,
153+
"bitbucket.org": ExternalReferenceType.VCS,
154+
# Social
155+
"discord.gg": ExternalReferenceType.SOCIAL,
156+
"discord.com": ExternalReferenceType.SOCIAL,
157+
"discordapp.com": ExternalReferenceType.SOCIAL,
158+
"glitter.im": ExternalReferenceType.SOCIAL,
159+
"mastodon.com": ExternalReferenceType.SOCIAL,
160+
"reddit.com": ExternalReferenceType.SOCIAL,
161+
"slack.com": ExternalReferenceType.SOCIAL,
162+
"youtube.com": ExternalReferenceType.SOCIAL,
163+
"youtu.be": ExternalReferenceType.SOCIAL,
164+
"twitter.com": ExternalReferenceType.SOCIAL,
165+
"x.com": ExternalReferenceType.SOCIAL,
166+
# Docs
167+
"readthedocs.io": ExternalReferenceType.DOCUMENTATION,
168+
# CI
169+
"ci.appveyor.com": ExternalReferenceType.QUALITY_METRICS,
170+
"circleci.com": ExternalReferenceType.QUALITY_METRICS,
171+
"codecov.io":ExternalReferenceType.QUALITY_METRICS,
172+
"coveralls.io": ExternalReferenceType.QUALITY_METRICS,
173+
"travis-ci.com": ExternalReferenceType.QUALITY_METRICS,
174+
"travis-ci.org": ExternalReferenceType.QUALITY_METRICS,
175+
# PyPI
176+
"cheeseshop.python.org": ExternalReferenceType.DISTRIBUTION,
177+
"pypi.io": ExternalReferenceType.DISTRIBUTION,
178+
"pypi.org": ExternalReferenceType.DISTRIBUTION,
179+
"pypi.python.org": ExternalReferenceType.DISTRIBUTION,
180+
# Python
181+
"python.org": ExternalReferenceType.WEBSITE,
141182
}
142-
143183
_NOCHAR_MATCHER = re_compile('[^a-z]')
144184

145185

0 commit comments

Comments
 (0)