1515
1616
1717def extract_name_version_from_link (link ):
18- # Github : https://github.com/(owner)/(repo)
19- # npm : https://www.npmjs.com/package/(package)/v/(version)
20- # npm2 : https://www.npmjs.com/package/@(group)/(package)/v/(version)
21- # pypi : https://pypi.org/project/(oss_name)/(version)
22- # pypi2 : https://files.pythonhosted.org/packages/source/(alphabet)/(oss_name)/(oss_name)-(version).tar.gz
23- # Maven: https://mvnrepository.com/artifact/(group)/(artifact)/(version)
24- # pub: https://pub.dev/packages/(package)/versions/(version)
25- # Cocoapods: https://cocoapods.org/(package)
26- pkg_pattern = {
27- "pypi" : r'https?:\/\/pypi\.org\/project\/([^\/]+)[\/]?([^\/]*)' ,
28- "pypi2" : r'https?:\/\/files\.pythonhosted\.org\/packages\/source\/[\w]\/([^\/]+)\/[\S]+-([^\-]+)\.tar\.gz' ,
29- "maven" : r'https?:\/\/mvnrepository\.com\/artifact\/([^\/]+)\/([^\/]+)\/?([^\/]*)' ,
30- "npm" : r'https?:\/\/www\.npmjs\.com\/package\/([^\/\@]+)(?:\/v\/)?([^\/]*)' ,
31- "npm2" : r'https?:\/\/www\.npmjs\.com\/package\/(\@[^\/]+\/[^\/]+)(?:\/v\/)?([^\/]*)' ,
32- "pub" : r'https?:\/\/pub\.dev\/packages\/([^\/]+)(?:\/versions\/)?([^\/]*)' ,
33- "pods" : r'https?:\/\/cocoapods\.org\/pods\/([^\/]+)'
34- }
3518 oss_name = ""
3619 oss_version = ""
3720 if link .startswith ("www." ):
3821 link = link .replace ("www." , "https://www." , 1 )
39- for key , value in pkg_pattern .items ():
22+ for key , value in constant . PKG_PATTERN .items ():
4023 p = re .compile (value )
4124 match = p .match (link )
4225 if match :
@@ -57,7 +40,7 @@ def extract_name_version_from_link(link):
5740 elif key == "pub" :
5841 oss_name = f"pub:{ origin_name } "
5942 oss_version = match .group (2 )
60- elif key == "pods " :
43+ elif key == "cocoapods " :
6144 oss_name = f"cocoapods:{ origin_name } "
6245 except Exception as ex :
6346 logger .info (f"extract_name_version_from_link { key } :{ ex } " )
0 commit comments