diff --git a/source/utils/urlUtils.py b/source/utils/urlUtils.py index 7eedb746d9f..08255ada106 100644 --- a/source/utils/urlUtils.py +++ b/source/utils/urlUtils.py @@ -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: diff --git a/tests/unit/test_util/test_urlUtils.py b/tests/unit/test_util/test_urlUtils.py index 1f642168c9d..a5132ffc9d9 100644 --- a/tests/unit/test_util/test_urlUtils.py +++ b/tests/unit/test_util/test_urlUtils.py @@ -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"))