fix: handle URLs already ending in /jsonrpc.php

NewClient() now detects when the provided URL already ends with
/jsonrpc.php and avoids appending it again. This prevents double-path
issues like /jsonrpc.php/jsonrpc.php.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Oliver Jakoubek 2026-01-27 10:27:23 +01:00
commit 96601980c3
4 changed files with 27 additions and 4 deletions

View file

@ -29,9 +29,15 @@ func NewClient(baseURL string) *Client {
// Ensure no trailing slash
baseURL = strings.TrimSuffix(baseURL, "/")
// Handle URLs that already include /jsonrpc.php
endpoint := baseURL
if !strings.HasSuffix(baseURL, "/jsonrpc.php") {
endpoint = baseURL + "/jsonrpc.php"
}
c := &Client{
baseURL: baseURL,
endpoint: baseURL + "/jsonrpc.php",
endpoint: endpoint,
}
c.httpClient = &http.Client{