@@ -476,9 +476,6 @@ def process_request(purl_str, **kwargs):
476476
477477
478478collect_links = re .compile (r'href="([^"]+)"' ).findall
479- collect_links_and_artifact_timestamps = re .compile (
480- r'<a href="([^"]+)".*</a>\s+(\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}|-)'
481- ).findall
482479
483480
484481def check_if_file_name_is_linked_on_page (file_name , links , ** kwargs ):
@@ -675,6 +672,62 @@ def filter_for_artifacts(timestamps_by_links):
675672 return timestamps_by_links_filtered
676673
677674
675+ def collect_links_and_artifact_timestamps (text ):
676+ # Return a list of sets containing all link locations and their
677+ # corresponding timestamps extracted from a given HTML text.
678+
679+ # Pattern that matches with https://repo.maven.apache.org/maven2
680+ maven_apache_pattern = re .compile (
681+ r'<a href="([^"]+)"[^>]*>[^<]*</a>\s+(\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}|-)'
682+ )
683+ maven_apache_matches = maven_apache_pattern .findall (text )
684+ if maven_apache_matches :
685+ return maven_apache_matches
686+
687+ # Pattern that matces with
688+ # both Apache (UTC) and Nexus (Z) formats
689+ # https://repository.jboss.org/nexus/service/rest/repository/browse/releases/
690+ # https://repository.jboss.org/nexus/service/rest/repository/browse/public/
691+ # https://repository.apache.org/snapshots/
692+ repo_jboss_apache_pattern = re .compile (
693+ r'<a href="([^"]+)"[^>]*>[^<]*</a></td>\s*<td>\s*((?:[A-Z][a-z]{2}\s+[A-Z][a-z]{2}\s+\d{1,2}\s+\d{2}:\d{2}:\d{2}\s+(?:UTC|Z)\s+\d{4})| )\s*</td>'
694+ )
695+ repo_jboss_apache_matches = repo_jboss_apache_pattern .findall (text )
696+ # Convert to empty string for table format
697+ if repo_jboss_apache_matches :
698+ return [
699+ (item , "" if timestamp == " " else timestamp )
700+ for item , timestamp in repo_jboss_apache_matches
701+ ]
702+
703+ # Pattern that matches with
704+ # https://repo.spring.io/milestone
705+ repo_spring_pattern = re .compile (
706+ r'<a href="([^"]+)"[^>]*>[^<]*</a>\s+(\d{2}-[A-Z][a-z]{2}-\d{4}\s+\d{2}:\d{2})'
707+ )
708+ repo_spring_matches = repo_spring_pattern .findall (text )
709+ if repo_spring_matches :
710+ return repo_spring_matches
711+
712+ # Simple links in <pre> tags without timestamps (Gradle plugins format)
713+ # https://plugins.gradle.org/m2/
714+ plugins_gradle_pattern = re .compile (r'<pre><a href="([^"]+)"[^>]*>[^<]*</a></pre>' )
715+ plugins_gradle_matches = plugins_gradle_pattern .findall (text )
716+ if plugins_gradle_matches :
717+ # Filter out parent directory link if present
718+ filtered_matches = []
719+ for href in plugins_gradle_matches :
720+ # Skip parent directory links
721+ if href != "../" and not href .startswith (".." ):
722+ filtered_matches .append ((href , "" ))
723+
724+ # Only return if we found non-parent links
725+ if filtered_matches :
726+ return filtered_matches
727+
728+ return []
729+
730+
678731def collect_links_from_text (text , filter ):
679732 """
680733 Return a mapping of link locations and their timestamps, given HTML `text`
@@ -700,7 +753,7 @@ def create_absolute_urls_for_links(text, url, filter):
700753 url = url .rstrip ("/" )
701754 timestamps_by_links = collect_links_from_text (text , filter )
702755 for link , timestamp in timestamps_by_links .items ():
703- if not link .startswith (url ):
756+ if not link .startswith ("http:" ) and not link . startswith ( "https:" ):
704757 link = f"{ url } /{ link } "
705758 timestamps_by_absolute_links [link ] = timestamp
706759 return timestamps_by_absolute_links
@@ -758,23 +811,20 @@ def get_artifact_sha1(artifact_url):
758811 return sha1
759812
760813
761- def get_classifier_from_artifact_url (
762- artifact_url , package_version_page_url , package_name , package_version
763- ):
814+ def get_classifier_from_artifact_url (artifact_url , package_name , package_version ):
764815 """
765816 Return the classifier from a Maven artifact URL `artifact_url`, otherwise
766817 return None if a classifier cannot be determined from `artifact_url`
767818 """
768819 classifier = None
769- # https://repo1.maven.org/maven2/net/alchim31/livereload-jvm/0.2.0
770- package_version_page_url = package_version_page_url .rstrip ("/" )
771- # https://repo1.maven.org/maven2/net/alchim31/livereload-jvm/0.2.0/livereload-jvm-0.2.0
772- leading_url_portion = f"{ package_version_page_url } /{ package_name } -{ package_version } "
820+ package_name_version_portion = f"{ package_name } -{ package_version } "
821+ artifact_url_filename = artifact_url .rsplit ("/" , 1 )[- 1 ]
822+ remaining_url_portion = artifact_url_filename .replace (package_name_version_portion , "" )
773823 # artifact_url = 'https://repo1.maven.org/maven2/net/alchim31/livereload-jvm/0.2.0/livereload-jvm-0.2.0-onejar.jar'
774- # ['', '-onejar.jar']
775- _ , remaining_url_portion = artifact_url .split (leading_url_portion )
776- # ['-onejar', 'jar']
824+ # artifact_url_filename = 'livereload-jvm-0.2.0-onejar.jar'
825+ # remaining_url_portion = '-onejar.jar'
777826 remaining_url_portions = remaining_url_portion .split ("." )
827+ # ['-onejar', 'jar']
778828 if remaining_url_portions and remaining_url_portions [0 ]:
779829 # '-onejar'
780830 classifier = remaining_url_portions [0 ]
0 commit comments