Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ignore hash based links #304

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def internal_to_external_urls(internal_url: str) -> str:
And [this is a correct relative link]({WORKING_INTERNAL_URL}).
And [this is an incorrect relative link]({BROKEN_INTERNAL_URL}).

This [hash link](#hash-link) should be ignored.

![Broken Image]({BROKEN_IMG_URL})
"""

Expand Down
8 changes: 8 additions & 0 deletions wiki/wiki/report/wiki_broken_links/wiki_broken_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ def get_broken_links(
broken_links = []
for el in links:
url = el.attrs.get("href") or el.attrs.get("src")

if is_hash_link(url):
continue

is_relative = is_relative_url(url)
relative_url = None

Expand All @@ -108,6 +112,10 @@ def is_relative_url(url: str) -> bool:
return url.startswith("/")


def is_hash_link(url: str) -> bool:
return url.startswith("#")


def is_broken_link(url: str) -> bool:
try:
status_code = get_request_status_code(url)
Expand Down
Loading