-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: parse default http ports in url, fixes #59 #61
base: master
Are you sure you want to change the base?
refactor: parse default http ports in url, fixes #59 #61
Conversation
This change correctly parses default http ports in url for rest and grpc packages.
@@ -47,7 +47,9 @@ export class QdrantClient { | |||
} | |||
const parsedUrl = new URL(url); | |||
this._host = parsedUrl.hostname; | |||
this._port = parsedUrl.port ? Number(parsedUrl.port) : port; | |||
const getPort = (url: string): number | null => | |||
url.includes(':443') ? 443 : url.includes(':80') ? 80 : port; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if url has localhost:8000
? url.includes(':80')
will still match
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case parsedUrl.port on line 52 will return 8000, so getPort
will not be invoked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, in which case getPort
will be invoked? If port is not specified explicitly? If so, why are we doing those checks for url.includes
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invoked in case of urls having default ports (443 for https and 80 for http) or no port specified.
#61 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I probably need a bit more context of what this PR fixes
Thanks for looking @generall , @kartik-gupta-ij For context, the url parser This change fixes this behavior. The issue was seen here - #59 |
This change correctly parses default http ports in url for rest and grpc packages.