MCPcopy
hub / github.com/scrapy/scrapy / potential_domain_matches

Function potential_domain_matches

scrapy/http/cookies.py:111–127  ·  view source on GitHub ↗

Potential domain matches for a cookie >>> potential_domain_matches('www.example.com') ['www.example.com', 'example.com', '.www.example.com', '.example.com']

(domain: str)

Source from the content-addressed store, hash-verified

109
110
111def potential_domain_matches(domain: str) -> list[str]:
112 """Potential domain matches for a cookie
113
114 >>> potential_domain_matches('www.example.com')
115 ['www.example.com', 'example.com', '.www.example.com', '.example.com']
116
117 """
118 matches = [domain]
119 try:
120 start = domain.index(".") + 1
121 end = domain.rindex(".")
122 while start < end:
123 matches.append(domain[start:])
124 start = domain.index(".", start) + 1
125 except ValueError:
126 pass
127 return matches + ["." + d for d in matches]
128
129
130class _DummyLock:

Callers 1

add_cookie_headerMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected