Potential domain matches for a cookie >>> potential_domain_matches('www.example.com') ['www.example.com', 'example.com', '.www.example.com', '.example.com']
(domain: str)
| 109 | |
| 110 | |
| 111 | def 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 | |
| 130 | class _DummyLock: |