Skip to content

Commit

Permalink
Improved support for codeload.github.com in url2purl #47
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Druez <[email protected]>
  • Loading branch information
tdruez committed Oct 5, 2021
1 parent 255e232 commit a29af1e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/packageurl/contrib/url2purl.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,11 @@ def build_github_api_purl(url):


# https://codeload.github.com/nexB/scancode-toolkit/tar.gz/v3.1.1
# https://codeload.github.com/berngp/grails-rest/zip/release/0.7
github_codeload_pattern = (
r"https?://codeload.github.com/"
r"(?P<namespace>.+)/(?P<name>.+)/(zip|tar.gz|tar.bz2|tgz)/v?(?P<version>.+)$"
r"https?://codeload.github.com/(?P<namespace>.+)/(?P<name>.+)/"
r"(zip|tar.gz|tar.bz2|tgz)/(.*/)*"
r"v?(?P<version>.+)$"
)

register_pattern('github', github_codeload_pattern)
Expand Down
3 changes: 2 additions & 1 deletion tests/contrib/data/url2purl.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@
"https://codeload.github.com/nexB/scancode-toolkit/zip/v3.1.1": "pkg:github/nexb/[email protected]",
"https://codeload.github.com/nexB/scancode.io/tar.gz/1.0": "pkg:github/nexb/[email protected]",
"https://codeload.github.com/nexB/scancode.io/tar.gz/v1.0": "pkg:github/nexb/[email protected]",
"https://codeload.github.com/berngp/grails-rest/zip/release/0.7": "pkg:github/berngp/[email protected]",
"https://codeload.github.com/eclipse/m2e-core/zip/releases/1.2/1.2.0.20120903-1050": "pkg:github/eclipse/[email protected]",
"https://github.com/nexB/scancode-toolkit/archive/3.1.1.zip": "pkg:github/nexb/[email protected]",
"https://github.com/nexB/scancode-toolkit/archive/v3.1.1.zip": "pkg:github/nexb/[email protected]",
"https://github.com/pypa/get-virtualenv/raw/20.0.31/public/virtualenv.pyz": "pkg:github/pypa/[email protected]#public/virtualenv.pyz",
Expand All @@ -217,7 +219,6 @@
"https://github.com/downloads/mozilla/rhino/rhino1_7R4.zip" : "pkg:github/mozilla/rhino@1_7R4",
"https://github.com/pombredanne/schematics.git" : "pkg:github/pombredanne/schematics",
"https://github.com/jgoerzen/configfile/archive/upstream/1.1.4.tar.gz": "pkg:github/jgoerzen/[email protected]",
"https://codeload.github.com/berngp/grails-rest/zip/release/0.7": "pkg:github/berngp/grails-rest@release/0.7",
"https://github.com/JetBrains/intellij-community/archive/idea/173.4710.11.zip": "pkg:github/jetbrains/[email protected]",
"https://github.com/knime/knime-core/archive/analytics-platform/3.6.0.zip": "pkg:github/knime/[email protected]",
"https://github.com/renozao/NMF/archive/hotfix/0.20.1.zip": "pkg:github/renozao/[email protected]",
Expand Down

0 comments on commit a29af1e

Please sign in to comment.