Merge pull request #6054 from netchampfaris/get-url-fix-2

fix: frappe.utils.get_url
This commit is contained in:
Faris Ansari 2018-09-05 18:44:22 +05:30 committed by GitHub
commit 0b1e62a0cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -728,13 +728,17 @@ def get_url(uri=None, full_address=False):
port = frappe.conf.http_port or frappe.conf.webserver_port
if host_name and ':' not in host_name and port:
if host_name and not url_contains_port(host_name) and port:
host_name = host_name + ':' + str(port)
url = urljoin(host_name, uri) if uri else host_name
return url
def url_contains_port(url):
parts = url.split(':')
return len(parts) > 2
def get_host_name():
return get_url().rsplit("//", 1)[-1]