Skip to content

Conversation

@alexbainter
Copy link
Collaborator

Closes #131.

This branch adds a new property to ReferenceItem called url_provider_info which returns an instance of a new URLProviderInfo class. This class can be extended to provide provider-specific functionality for ReferenceItems based on their URL providers. In this case, GitHubURLInfo was added for GitHub urls, including raw_url and repo_url computed properties.

if reference_item.url_provider_info.provider_name == 'GitHub': # or GitHubURLInfo.provider_name
    print(reference_item.url_provider_info.raw_url)
    print(reference_item.url_provider_info.repo_url)

I considered just treating GitHub as a special case and adding these helpers directly to the ReferenceItem class but I wanted an approach that would work well with other providers down the road.

@alexbainter alexbainter requested a review from lisad December 29, 2025 19:55
self.url = url

@classmethod
def from_url(cls, url):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooh a proper Class Factory!

@alexbainter alexbainter merged commit 3c9b254 into main Dec 30, 2025
8 checks passed
@alexbainter alexbainter deleted the alex-131-github-link-coversion branch December 30, 2025 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Infer raw URL from github page URL and vice versa

2 participants