DRYer: Get hostname

This commit is contained in:
pagedown
2022-11-26 15:28:32 +08:00
parent 63a08dc6cc
commit 6a1b456bac
4 changed files with 20 additions and 15 deletions

View File

@@ -853,11 +853,8 @@ class Window:
return
if (not purl.scheme or purl.scheme == 'file'):
if purl.netloc:
from socket import gethostname
try:
hostname = gethostname()
except Exception:
hostname = ''
from .utils import get_hostname
hostname = get_hostname()
remote_hostname = purl.netloc.partition(':')[0]
if remote_hostname and remote_hostname != hostname and remote_hostname != 'localhost':
self.handle_remote_file(purl.netloc, unquote(purl.path))