Skip to content

Commit e3d40fe

Browse files
authored
feat: remove trailing slash from connection URL (influxdata#93)
1 parent e68cf1a commit e3d40fe

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
### Bug Fixes
77
1. [#85](https://github.com/influxdata/influxdb-client-python/issues/85): Fixed a possibility to generate empty write batch
88
2. [#86](https://github.com/influxdata/influxdb-client-python/issues/86): BREAKING CHANGE: Fixed parameters in delete api - now delete api accepts also bucket name and org name instead of only ids
9+
1. [#93](https://github.com/influxdata/influxdb-client-python/pull/93): Remove trailing slash from connection URL
910

1011
## 1.6.0 [2020-04-17]
1112

influxdb_client/client/influxdb_client.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ def __init__(self, url, token, debug=None, timeout=10000, enable_gzip=False, org
4040
self.default_tags = default_tags
4141

4242
conf = _Configuration()
43-
conf.host = self.url
43+
if self.url.endswith("/"):
44+
conf.host = self.url[:-1]
45+
else:
46+
conf.host = self.url
4447
conf.enable_gzip = enable_gzip
4548
conf.debug = debug
4649

tests/test_BucketsApi.py

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def test_create_delete_bucket(self):
3737
assert self.buckets_api.find_bucket_by_id(my_bucket.id)
3838
assert "bucket not found" in e.value.body
3939

40+
@pytest.mark.skip(reason="https://github.com/influxdata/influxdb/issues/14900")
4041
def test_find_by_name(self):
4142
my_org = self.find_my_org()
4243

tests/test_InfluxDBClient.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import unittest
2+
3+
from influxdb_client import InfluxDBClient
4+
5+
6+
class InfluxDBClientTest(unittest.TestCase):
7+
8+
def test_TrailingSlashInUrl(self):
9+
client = InfluxDBClient(url="http://localhost:9999", token="my-token", org="my-org")
10+
self.assertEqual('http://localhost:9999', client.api_client.configuration.host)
11+
12+
client = InfluxDBClient(url="http://localhost:9999/", token="my-token", org="my-org")
13+
self.assertEqual('http://localhost:9999', client.api_client.configuration.host)

0 commit comments

Comments
 (0)