Merge "If endpoint ends with 1 client removes it"
This commit is contained in:
@@ -20,6 +20,7 @@ import http.client
|
||||
import io
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import socket
|
||||
import ssl
|
||||
import textwrap
|
||||
@@ -61,7 +62,7 @@ SUPPORTED_ENDPOINT_SCHEME = ('http', 'https')
|
||||
|
||||
def _trim_endpoint_api_version(url):
|
||||
"""Trim API version and trailing slash from endpoint."""
|
||||
return url.rstrip('/').rstrip(API_VERSION)
|
||||
return re.sub(f'{API_VERSION}$', '', url.rstrip('/'))
|
||||
|
||||
|
||||
def _extract_error_json(body):
|
||||
|
@@ -358,3 +358,8 @@ class ClientTest(utils.BaseTestCase):
|
||||
client = httpclient.HTTPClient(endpoint)
|
||||
conn_url = client._make_connection_url(url)
|
||||
self.assertEqual(expected_url, conn_url)
|
||||
|
||||
def test_port_ends_with_one(self):
|
||||
endpoint = "http://localhost:8081/"
|
||||
http_client = httpclient.HTTPClient(endpoint)
|
||||
self.assertEqual(endpoint, http_client._make_connection_url(""))
|
||||
|
Reference in New Issue
Block a user