Change magic link request to use url builder

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-01-16 09:29:44 +04:00
committed by Bryan Frimin
parent a6826826b0
commit 5beceb58d2
3 changed files with 8 additions and 39 deletions

View File

@@ -116,15 +116,12 @@ type URLBuilder struct {
}
// WithPath returns a URLBuilder with the specified path.
// The path will be properly joined with the base URL.
// The path will be properly joined with the base URL's path.
func (b *BaseURL) WithPath(path string) *URLBuilder {
if b == nil {
return &URLBuilder{err: fmt.Errorf("base URL is nil")}
}
// Ensure path does not end with /
basePath := strings.TrimSuffix(b.parsed.Path, "/")
// Ensure path starts with /
if !strings.HasPrefix(path, "/") {
path = "/" + path
@@ -135,30 +132,11 @@ func (b *BaseURL) WithPath(path string) *URLBuilder {
return &URLBuilder{
base: b,
path: basePath + path,
path: path,
query: make(url.Values),
}
}
// WithPath returns a URLBuilder with the specified path.
// The path will be properly joined with the base URL.
func (ub *URLBuilder) WithPath(path string) *URLBuilder {
if ub == nil {
return ub
}
// Ensure path starts with /
if !strings.HasPrefix(path, "/") {
path = "/" + path
}
// Ensure path does not end with /
path = strings.TrimSuffix(path, "/")
ub.path = ub.path + path
return ub
}
// WithQuery adds a query parameter to the URL.
func (ub *URLBuilder) WithQuery(key, value string) *URLBuilder {
if ub.err != nil {