Skip to content

Commit 361b0fa

Browse files
committed
Handle all srv domains not just < 3 parts
1 parent 577cd7f commit 361b0fa

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

pymongo/asynchronous/srv_resolver.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ def __init__(
9292
pass
9393

9494
try:
95-
self.__plist = self.__fqdn.split(".")
95+
self.__plist = (
96+
self.__fqdn.split(".")[1:]
97+
if len(self.__fqdn.split(".")) > 2
98+
else self.__fqdn.split(".")
99+
)
96100
except Exception:
97101
raise ConfigurationError(_INVALID_HOST_MSG % (fqdn,)) from None
98102
self.__slen = len(self.__plist)

pymongo/synchronous/srv_resolver.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ def __init__(
9292
pass
9393

9494
try:
95-
self.__plist = self.__fqdn.split(".")
95+
self.__plist = (
96+
self.__fqdn.split(".")[1:]
97+
if len(self.__fqdn.split(".")) > 2
98+
else self.__fqdn.split(".")
99+
)
96100
except Exception:
97101
raise ConfigurationError(_INVALID_HOST_MSG % (fqdn,)) from None
98102
self.__slen = len(self.__plist)

0 commit comments

Comments
 (0)