We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
RequestConfig.Execute
package main import ( "log" "net/url" "strings" ) func main() { baseURLString := "http://base.url/some/path/v1" cfgRequestPath := "chat/completions" expectedURLString := "http://base.url/some/path/v1/chat/completions" baseURL, err := url.Parse(baseURLString) if err != nil { log.Fatal(err) } resultURL, err := baseURL.Parse(strings.TrimLeft(cfgRequestPath, "/")) if err != nil { log.Fatal(err) } log.Println("result URL == expected URL", resultURL.String() == expectedURLString) log.Println("expected URL", expectedURLString) log.Println("result URL", resultURL.String()) }
result URL == expected URL false expected URL http://base.url/some/path/v1/chat/completions result URL http://base.url/some/path/chat/completions
The URL construction logic is flawed, as it overwrites the last part of the BaseURL if it lacks a trailing slash.
BaseURL
Ensure that the BaseURL consistently ends with a trailing slash to prevent accidental truncation during path joining.
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
How to reproduce an isolated problem: https://go.dev/play/p/I0RUm0AIx_2
Actual result:
The URL construction logic is flawed, as it overwrites the last part of the
BaseURL
if it lacks a trailing slash.Suggested fix:
Ensure that the
BaseURL
consistently ends with a trailing slash to prevent accidental truncation during path joining.The text was updated successfully, but these errors were encountered: