Skip to content

Improve GitHub archiving - #353

Merged
NGTmeaty merged 16 commits into
mainfrom
improve-github-archiving
Jun 24, 2025
Merged

NGTmeaty merged 16 commits into
mainfrom
improve-github-archiving

Conversation

@yzqzss

@yzqzss yzqzss commented Jun 21, 2025 •

Copy link
Copy Markdown
Collaborator

Improved the archiving quality of GitHub Issue&PR pages.

26e6dd2, f94197f fix:
I noticed that some "data:" URLs were being queued that should have been filtered => We forgot to call filterURLsByProtocol() for assets.

e543bb3 fix:
GitHub has rewritten the issue pages in react in recent months. Now they embed many useful (images, videos, user avatars...) assets into HTML <script> tags as JSON for issue pages.
image

These assets are in JSON strings.
image

and JSON extractor currently only considers an asset if the entire string is a valid URL.

49de5c7 improved:
These GitHub assets have no file suffix, so a sitespecific/github.go patch was added to JSON extractor to treat them as assets.

daa9ee8 fix:
hasFileExtension() wrongly considers Protocol and domain only, no path links like https://example.com to have a suffix.

92241c7: make isValidURL() check more robust

fe3f888 Changed: Renamed the original LinkRegex to QuotedLinkRegex to reflect its actual purpose. The new LinkRegex is copyied and adapted from heritrix3. :)

Comment thread internal/pkg/postprocessor/sitespecific/github/github.go Fixed
Comment thread internal/pkg/postprocessor/sitespecific/github/github.go Fixed
Comment thread internal/pkg/postprocessor/sitespecific/github/github.go Fixed
Comment thread internal/pkg/postprocessor/sitespecific/github/github.go Fixed
Comment thread internal/pkg/postprocessor/sitespecific/github/github.go Fixed
Comment thread internal/pkg/postprocessor/sitespecific/github/github.go Fixed
Comment thread internal/pkg/postprocessor/sitespecific/github/github.go Fixed
Comment thread internal/pkg/postprocessor/sitespecific/github/github.go Fixed
@yzqzss
yzqzss force-pushed the improve-github-archiving branch from a693bbe to 293c3eb Compare June 21, 2025 14:54
@yzqzss

yzqzss commented Jun 21, 2025

Copy link
Copy Markdown
Collaborator Author

Before (left window), after (right window):

2025-06-21.23-56-01.mp4

You can see that the avatars, pictures, and video attachment have been captured correctly.

Example issue url: https://github[.]com/webrecorder/browsertrix-behaviors/issues/58

@yzqzss
yzqzss requested a review from Copilot June 21, 2025 16:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances URL filtering and extraction to improve archiving quality, especially for GitHub Issue/PR pages.

  • Introduced filterURLsByProtocol to exclude unwanted protocols (e.g., data:, file:).
  • Expanded JSON extractor to detect URLs in text fields and treat GitHub-specific asset patterns as assets.
  • Updated tests and core logic for file-extension detection, URL validation, and GitHub asset recognition.

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
internal/pkg/postprocessor/utils.go Added skipProtocolsRe and filterURLsByProtocol for protocol-based URL filtering.
internal/pkg/postprocessor/sitespecific/github/github_test.go Added unit tests for ShouldConsiderAsAsset covering various GitHub URL patterns.
internal/pkg/postprocessor/sitespecific/github/github.go Implemented ShouldConsiderAsAsset with regex matchers for GitHub asset URLs.
internal/pkg/postprocessor/outlinks.go Removed duplicate filterURLsByProtocol and skipProtocolsRe, centralizing filtering logic.
internal/pkg/postprocessor/extractor/xml_test.go Adjusted expected indices in XML feed test after parsing changes.
internal/pkg/postprocessor/extractor/utils_test.go Added tests ensuring domain-only URLs are not considered as having file extensions.
internal/pkg/postprocessor/extractor/utils.go Enhanced hasFileExtension to strip query/fragment and exclude protocol-only URLs.
internal/pkg/postprocessor/extractor/json_test.go Refactored JSON tests to separate assets/outlinks and added text-link extraction cases.
internal/pkg/postprocessor/extractor/json.go Extended JSON extraction: added text-link detection and GitHub asset handling in GetURLsFromJSON.
internal/pkg/postprocessor/extractor/html.go Replaced commented logger call with structured logger.Debug for script-JSON errors.
internal/pkg/postprocessor/assets.go Applied filterURLsByProtocol to both assets and outlinks before finalizing extraction.
Comments suppressed due to low confidence (1)

internal/pkg/postprocessor/sitespecific/github/github.go:24

  • [nitpick] The variable name regexGithubAsset is inconsistent with the githubAvatar, githubAssets, etc. prefix. Consider renaming it to something like githubRepoAssetsRe to match the naming style of other regex variables.
var regexGithubAsset = regexp.MustCompile(`(?i)https://github\.com/[^/]+/[^/]+/assets/`)

Comment thread internal/pkg/postprocessor/extractor/json.go Outdated
yzqzss and others added 2 commits June 22, 2025 00:18
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@yzqzss

yzqzss commented Jun 21, 2025 •

Copy link
Copy Markdown
Collaborator Author

Ready for review :)

@NGTmeaty NGTmeaty left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you! These improvements look super solid and very helpful! I had a couple of small questions in my review:

Comment thread internal/pkg/postprocessor/extractor/json.go Outdated
Comment thread internal/pkg/postprocessor/sitespecific/github/github.go Outdated
@yzqzss

yzqzss commented Jun 24, 2025 •

Copy link
Copy Markdown
Collaborator Author

Also renamed the original LinkRegex to QuotedLinkRegex to reflect its actual purpose.
The new LinkRegex is copied and adapted from heritrix3. :)

fe3f888

@NGTmeaty NGTmeaty left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks! Changes look great!

@NGTmeaty
NGTmeaty merged commit 2389e71 into main Jun 24, 2025
@yzqzss
yzqzss deleted the improve-github-archiving branch July 14, 2025 17:17
@yzqzss yzqzss added the GSoC label Aug 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants