~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
fix(url_utils): lowercase IPv6 hosts in canonical_url_key (#6663) (#6665)
Suprovo Mallick (DYNO)eacd7f8669b4
diff --git a/changelog.d/6665.bugfix.md b/changelog.d/6665.bugfix.mdnew file mode 100644index 0000000000..a26b891ce2--- /dev/null+++ b/changelog.d/6665.bugfix.md@@ -0,0 +1 @@+Lowercase IPv6 host addresses in `canonical_url_key` while preserving case-sensitive RFC 6874 zone identifiers and port specifications.diff --git a/src/local_deep_research/utilities/url_utils.py b/src/local_deep_research/utilities/url_utils.pyindex 58e5c9288b..ea79ff672c 100644--- a/src/local_deep_research/utilities/url_utils.py+++ b/src/local_deep_research/utilities/url_utils.py@@ -494,7 +494,13 @@ def canonical_url_key(url: str) -> str:# Split host/port carefully so IPv6 literals survive.if netloc.startswith("["):end = netloc.find("]")- host = netloc[: end + 1]+ raw_host = netloc[: end + 1]+ # Lowercase IPv6 address portion while preserving case-sensitive zone ID (RFC 6874)+ if "%" in raw_host:+ addr, zone = raw_host.split("%", 1)+ host = f"{addr.lower()}%{zone}"+ else:+ host = raw_host.lower()rest = netloc[end + 1 :]port = rest[1:] if rest.startswith(":") else ""elif ":" in netloc:diff --git a/tests/utilities/test_url_utils.py b/tests/utilities/test_url_utils.pyindex b0e4be3c25..f5f504b233 100644--- a/tests/utilities/test_url_utils.py+++ b/tests/utilities/test_url_utils.py@@ -234,6 +234,40 @@ class TestCanonicalUrlKey:== "https://[::1]:8443/page")+ def test_ipv6_host_lowercased(self):+ from local_deep_research.utilities.url_utils import canonical_url_key++ assert (+ canonical_url_key("https://[2001:DB8::1]/source")+ == "https://[2001:db8::1]/source"+ )+ assert canonical_url_key(+ "https://[2001:DB8::1]/source"+ ) == canonical_url_key("https://[2001:db8::1]/source")+ assert (+ canonical_url_key("https://[2001:DB8::1]:8443/page")+ == "https://[2001:db8::1]:8443/page"+ )++ # Scoped IPv6: lowercase address portion while preserving case-sensitive zone ID (RFC 6874)+ assert (+ canonical_url_key("https://[fe80::ABCD%25eth0]/source")+ == "https://[fe80::abcd%25eth0]/source"+ )+ # Address-case variants with the same zone deduplicate+ assert canonical_url_key(+ "https://[fe80::ABCD%25eth0]/source"+ ) == canonical_url_key("https://[fe80::abcd%25eth0]/source")+ # Differently-cased zones remain distinct+ assert canonical_url_key(+ "https://[fe80::1%25eth0]/source"+ ) != canonical_url_key("https://[fe80::1%25Eth0]/source")+ # Non-default port retained with scoped IPv6+ assert (+ canonical_url_key("https://[fe80::ABCD%25eth0]:8443/page")+ == "https://[fe80::abcd%25eth0]:8443/page"+ )+def test_library_route_keys_per_document(self):"""All views of one library document share a dedup key.