weaviate / typescript-client

Official Weaviate TypeScript Client
https://www.npmjs.com/package/weaviate-client
BSD 3-Clause "New" or "Revised" License
65 stars 23 forks source link

Handle existing scheme in host #88

Closed thomashacker closed 1 year ago

thomashacker commented 1 year ago

This PR aims to fix https://github.com/weaviate/typescript-client/issues/87 and adds a simple check before creating the baseUrl

const version = '/v1';
const baseUri = config.host.startsWith(`${config.scheme}://`)
    ? `${config.host}${version}`
    : `${config.scheme}://${config.host}${version}`;

This allows users to use a host URL with a scheme if it matches the specified scheme.

The PR also adds two unit tests to verify that it constructs the correct URLs.

weaviate-git-bot commented 1 year ago

To avoid any confusion in the future about your contribution to Weaviate, we work with a Contributor License Agreement. If you agree, you can simply add a comment to this PR that you agree with the CLA so that we can merge.

beep boop - the Weaviate bot 👋🤖

PS:
Are you already a member of the Weaviate Slack channel?

thomashacker commented 1 year ago

I agree,

As far as I can see, the scheme parameter is only being used to build the baseURL for both the HTTPClient and GQLClient. As you suggested, If the scheme is already present in the host, we can make specifying the scheme optional.

I would also move the whole scheme/host processing upwards, I'll look into it!

thomashacker commented 1 year ago