TestURLDetection Class — langchain Architecture
Architecture documentation for the TestURLDetection class in test_pii.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 20a7ba9e_05c6_7daa_b413_28997f2af3d2["TestURLDetection"] 6dcffc03_fae9_01f8_ed9b_d30d8a73dd13["test_pii.py"] 20a7ba9e_05c6_7daa_b413_28997f2af3d2 -->|defined in| 6dcffc03_fae9_01f8_ed9b_d30d8a73dd13 7d6d7acf_37b8_2139_fdce_cd02440f0b8f["test_detect_http_url()"] 20a7ba9e_05c6_7daa_b413_28997f2af3d2 -->|method| 7d6d7acf_37b8_2139_fdce_cd02440f0b8f 9d6f585b_efc9_a081_c6ea_26591c39a891["test_detect_https_url()"] 20a7ba9e_05c6_7daa_b413_28997f2af3d2 -->|method| 9d6f585b_efc9_a081_c6ea_26591c39a891 d873edca_d1a0_47a0_07e0_f10e9abcfc0c["test_detect_www_url()"] 20a7ba9e_05c6_7daa_b413_28997f2af3d2 -->|method| d873edca_d1a0_47a0_07e0_f10e9abcfc0c 1982ff7c_302e_5d66_cfe5_0873cd1c8a77["test_detect_bare_domain_with_path()"] 20a7ba9e_05c6_7daa_b413_28997f2af3d2 -->|method| 1982ff7c_302e_5d66_cfe5_0873cd1c8a77 c1ef844d_2777_c453_cad4_4946b7e6eff5["test_detect_multiple_urls()"] 20a7ba9e_05c6_7daa_b413_28997f2af3d2 -->|method| c1ef844d_2777_c453_cad4_4946b7e6eff5 db7141ee_b828_bbb0_7696_86fc5d6ad93f["test_no_url()"] 20a7ba9e_05c6_7daa_b413_28997f2af3d2 -->|method| db7141ee_b828_bbb0_7696_86fc5d6ad93f 18901f95_df60_7f68_c1bb_082ffa710b2e["test_bare_domain_without_path_not_detected()"] 20a7ba9e_05c6_7daa_b413_28997f2af3d2 -->|method| 18901f95_df60_7f68_c1bb_082ffa710b2e
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_pii.py lines 175–223
class TestURLDetection:
"""Test URL detection."""
def test_detect_http_url(self) -> None:
content = "Visit http://example.com for details."
matches = detect_url(content)
assert len(matches) == 1
assert matches[0]["type"] == "url"
assert matches[0]["value"] == "http://example.com"
def test_detect_https_url(self) -> None:
content = "Visit https://secure.example.com/path"
matches = detect_url(content)
assert len(matches) == 1
assert matches[0]["value"] == "https://secure.example.com/path"
def test_detect_www_url(self) -> None:
content = "Check www.example.com"
matches = detect_url(content)
assert len(matches) == 1
assert matches[0]["value"] == "www.example.com"
def test_detect_bare_domain_with_path(self) -> None:
content = "Go to example.com/page"
matches = detect_url(content)
assert len(matches) == 1
assert matches[0]["value"] == "example.com/page"
def test_detect_multiple_urls(self) -> None:
content = "Visit http://test.com and https://example.org"
matches = detect_url(content)
assert len(matches) == 2
def test_no_url(self) -> None:
content = "No URLs here."
matches = detect_url(content)
assert len(matches) == 0
def test_bare_domain_without_path_not_detected(self) -> None:
# To reduce false positives, bare domains without paths are not detected
content = "The word example.com in prose"
detect_url(content)
# May or may not detect depending on implementation
# This is acceptable
Source
Frequently Asked Questions
What is the TestURLDetection class?
TestURLDetection is a class in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_pii.py.
Where is TestURLDetection defined?
TestURLDetection is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_pii.py at line 175.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free