Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/connection/connections/HttpConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default class HttpConnection implements IConnectionProvider {

this.connection = new ThriftHttpConnection(
{
url: `${options.https ? 'https' : 'http'}://${options.host.replace(/\/$/, '')}:${options.port}${options.path ? ('/' + options.path.replace(/\/$/, '')) : '/'}`,
url: `${options.https ? 'https' : 'http'}://${options.host.replace(/\/$/, '')}:${options.port}${options.path ?? '/'}`,
transport: thrift.TBufferedTransport,
protocol: thrift.TBinaryProtocol,
getRetryPolicy: () => this.getRetryPolicy(),
Expand Down
12 changes: 4 additions & 8 deletions tests/unit/connection/connections/HttpConnection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ describe('HttpConnection.connect', () => {
});
});

it('should handle trailing slashes in host and path correctly', async () => {
it('should handle trailing slashes in host correctly', async () => {
interface TestCase {
input: {
host: string;
Expand All @@ -139,19 +139,15 @@ describe('HttpConnection.connect', () => {

const testCases: TestCase[] = [
{
input: { host: 'xyz.com/', path: '/sql/v1/' },
input: { host: 'xyz.com/', path: '/sql/v1' },
expected: 'https://xyz.com:443/sql/v1'
},
{
input: { host: 'xyz.com', path: 'sql/v1' },
input: { host: 'xyz.com', path: '/sql/v1' },
expected: 'https://xyz.com:443/sql/v1'
},
{
input: { host: 'xyz.com/', path: 'sql/v1' },
expected: 'https://xyz.com:443/sql/v1'
},
{
input: { host: 'xyz.com', path: undefined },
input: { host: 'xyz.com/', path: undefined },
expected: 'https://xyz.com:443/'
}
];
Expand Down
Loading