@@ -692,22 +692,17 @@ def build_gitlab_sub_purl(url):
692692
693693 gitlab_sub_commit_pattern = (
694694 r"^https?://"
695- r"(?P<domain>[^/]+)/"
696695 r"(?P<namespace>.+?)/"
697696 r"(?P<name>[^/]+)"
698- r"(?:/(?:-/)? commit/(?P<version>[0-9a-fA-F]{7,64}))?"
697+ r"(?:/-/ commit/(?P<version>[0-9a-fA-F]{7,64}))?"
699698 r"/?$"
700699 )
701700
702701 commit_match = re .search (gitlab_sub_commit_pattern , url )
703702 if commit_match :
704- domain = commit_match .group ("domain" )
705- raw_namespace = commit_match .group ("namespace" ).strip ("/" )
706- namespace = f"{ domain } /{ raw_namespace } "
707-
708703 return PackageURL (
709704 type = "generic" ,
710- namespace = namespace ,
705+ namespace = commit_match . group ( " namespace" ) ,
711706 name = commit_match .group ("name" ),
712707 version = commit_match .group ("version" ),
713708 )
@@ -730,27 +725,21 @@ def build_gitea_purl(url):
730725
731726 gitea_commit_pattern = (
732727 r"^https?://"
733- r"(?P<domain>[^/]+)/"
734- r"(?P<namespace>[^/]+)/"
728+ r"(?P<namespace>.+?)/"
735729 r"(?P<name>[^/]+)"
736730 r"(?:/commit/(?P<version>[0-9a-fA-F]{7,64}))?"
737731 r"/?$"
738732 )
739733
740734 commit_match = re .search (gitea_commit_pattern , url )
741735 if commit_match :
742- domain = commit_match .group ("domain" )
743- namespace = f"{ domain } /{ commit_match .group ('namespace' )} "
744-
745736 return PackageURL (
746737 type = "generic" ,
747- namespace = namespace ,
738+ namespace = commit_match . group ( ' namespace' ) ,
748739 name = commit_match .group ("name" ),
749740 version = commit_match .group ("version" ),
750741 )
751742
752- return
753-
754743
755744CGIT_DOMAINS = [
756745 r"git\.kernel\.org" ,
@@ -781,15 +770,14 @@ def build_cgit_purl(url):
781770 https://git.kernel.org/stable/c/9a9a8fe26751334b7739193a94eba741073b8a55
782771 """
783772
773+ # https://git.kernel.org/stable/c/<hash>
784774 kernel_shorthand = (
785- r"^https?://(?P<domain>git\.kernel\.org)/"
786- r"(?P<name>[^/]+)/c/"
775+ r"^https?://git\.kernel\.org/stable/c/"
787776 r"(?P<version>[0-9a-fA-F]{7,64})/?$"
788777 )
789778
790779 cgit_project_pattern = (
791780 r"^https?://"
792- r"(?P<domain>[^/]+)/"
793781 r"(?P<namespace>.+?)/"
794782 r"(?P<name>[^/]+?)"
795783 r"(?:\.git)?"
@@ -799,17 +787,19 @@ def build_cgit_purl(url):
799787
800788 if match := re .search (kernel_shorthand , url ):
801789 res = match .groupdict ()
802- namespace = res ["domain" ]
790+ namespace = "git.kernel.org/pub/scm/linux/kernel/git/stable/"
791+ name = "linux"
803792 elif match := re .search (cgit_project_pattern , url ):
804793 res = match .groupdict ()
805- namespace = f"{ res ['domain' ]} /{ res ['namespace' ]} "
794+ name = res ["name" ]
795+ namespace = res ['namespace' ]
806796 else :
807797 return None
808798
809799 return PackageURL (
810800 type = "generic" ,
811801 namespace = namespace ,
812- name = res [ " name" ] ,
802+ name = name ,
813803 version = res ["version" ],
814804 qualifiers = {},
815805 subpath = "" ,
@@ -838,21 +828,17 @@ def build_gitiles_purl(url):
838828
839829 gitiles_project_pattern = (
840830 r"^https?://"
841- r"(?P<domain>[^/]+)/"
842- r"(?:(?P<namespace>(?:(?!/\+/).)+)/)?"
843- r"(?P<name>(?:(?!/\+/)[^/])+)"
831+ r"(?P<namespace>(?:(?!/\+/).)+)/"
832+ r"(?P<name>[^/]+)"
844833 r"(?:/\+/(?P<version>[0-9a-fA-F]{7,64}))?"
845834 r"/?$"
846835 )
847836
848837 match = re .search (gitiles_project_pattern , url )
849838 if match :
850- raw_namespace = match .group ("namespace" )
851- domain = match .group ("domain" )
852- namespace = f"{ domain } /{ raw_namespace } " if raw_namespace else domain
853839 return PackageURL (
854840 type = "generic" ,
855- namespace = namespace ,
841+ namespace = match . group ( " namespace" ) ,
856842 name = match .group ("name" ),
857843 version = match .group ("version" ),
858844 qualifiers = {},
@@ -879,7 +865,6 @@ def build_allura_purl(url):
879865
880866 allura_pattern = (
881867 r"^https?://"
882- r"(?P<domain>[^/]+)/"
883868 r"(?P<namespace>.+?)/"
884869 r"(?P<name>[^/]+?)"
885870 r"(?:/ci/(?P<version>[0-9a-fA-F]{7,64}))?"
@@ -888,11 +873,9 @@ def build_allura_purl(url):
888873
889874 commit_match = re .search (allura_pattern , url )
890875 if commit_match :
891- domain = commit_match .group ("domain" )
892- namespace = f"{ domain } /{ commit_match .group ('namespace' )} "
893876 return PackageURL (
894877 type = "generic" ,
895- namespace = namespace ,
878+ namespace = commit_match . group ( ' namespace' ) ,
896879 name = commit_match .group ("name" ),
897880 version = commit_match .group ("version" ),
898881 qualifiers = {},
@@ -905,6 +888,7 @@ def build_allura_purl(url):
905888 r"git\.postgresql\.org/gitweb" ,
906889 "sourceware\.org/git" ,
907890 "git\.openssl\.org/gitweb" ,
891+ "gitbox\.apache\.org" ,
908892]
909893GITWEB_ROUTE_REGEX = build_route_regex (GITWEB_DOMAINS )
910894
@@ -920,6 +904,7 @@ def build_gitweb_purl(url):
920904 https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=82cc94e5fb69d1c45a386f83798251de5bff9339
921905 https://git.postgresql.org/gitweb/?p=hamn.git;a=commit;h=a796b71a5b3fe7f751f1086a08cb114b9877dea2
922906 https://sourceware.org/git/?p=glibc.git;a=commit;h=dedebed24f77762eea7d3c5ed2739a90a4d60461
907+ https://gitbox.apache.org/repos/asf?p=xalan-java.git;a=commit;h=da3e0d06b467247643ce04e88d3346739d119f21
923908 """
924909
925910 gitweb_pattern = (
0 commit comments