File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ def host_is_name_part(address: str) -> bool:
4545
4646def address_is_local (address : str ) -> bool :
4747 """Return True if the address is a local address."""
48- return address .removesuffix ("." ).endswith (".local" )
48+ return address .removesuffix ("." ).lower (). endswith (".local" )
4949
5050
5151def is_ip_address (address : str | None ) -> bool :
Original file line number Diff line number Diff line change 55import pytest
66
77from aioesphomeapi import util
8- from aioesphomeapi .util import is_ip_address
8+ from aioesphomeapi .util import address_is_local , is_ip_address
99
1010
1111@pytest .mark .parametrize (
@@ -119,3 +119,22 @@ async def _eager_task():
119119)
120120def test_is_ip_address (address : str | None , expected : bool ) -> None :
121121 assert is_ip_address (address ) is expected
122+
123+
124+ @pytest .mark .parametrize (
125+ ("address" , "expected" ),
126+ [
127+ ("myesp.local" , True ),
128+ ("myesp.local." , True ),
129+ # mDNS / DNS names are case-insensitive (RFC 6762 §16, RFC 4343).
130+ ("MyESP.LOCAL" , True ),
131+ ("myesp.Local" , True ),
132+ ("MYESP.LOCAL." , True ),
133+ ("myesp" , False ),
134+ ("myesp.localdomain" , False ),
135+ ("host.example.com" , False ),
136+ ("" , False ),
137+ ],
138+ )
139+ def test_address_is_local (address : str , expected : bool ) -> None :
140+ assert address_is_local (address ) is expected
You can’t perform that action at this time.
0 commit comments