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

Report same page links on local files #17161

Merged
merged 7 commits into from
Sep 18, 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
2 changes: 1 addition & 1 deletion source/utils/urlUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def isSamePageURL(targetURLOnPage: str, rootURL: str) -> bool:
if not targetURLOnPage or not rootURL:
return False

validSchemes = ("http", "https")
validSchemes = ("http", "https", "file")
# Parse the URLs
parsedTargetURLOnPage: ParseResult = urlparse(targetURLOnPage)
if parsedTargetURLOnPage.scheme not in validSchemes:
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/test_util/test_urlUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ def test_unusualCharacters(self):
"""Test URLs with unusual characters."""
self.assertTrue(isSamePageURL("http://example.com/page#%E2%9C%93", "http://example.com/page"))

def test_externalLinkInLocalFile(self):
"""Test external link in local file."""
self.assertFalse(isSamePageURL("http://example.com/page#section", "file:///file"))

def test_ftpScheme(self):
"""Test URLs with different schemes like FTP."""
self.assertFalse(isSamePageURL("ftp://example.com/page#section", "http://example.com/page"))
Expand Down