Merge "If endpoint ends with 1 client removes it"

This commit is contained in:
Zuul
2025-01-09 23:05:34 +00:00
committed by Gerrit Code Review
2 changed files with 7 additions and 1 deletions

View File

@@ -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):

View File

@@ -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(""))