Skip to content

fix(downloader): apply url_base to download-client base URL (#369)#375

Merged
vavallee merged 1 commit intovavallee:mainfrom
SAY-5:fix/download-client-url-base-369
Apr 24, 2026
Merged

fix(downloader): apply url_base to download-client base URL (#369)#375
vavallee merged 1 commit intovavallee:mainfrom
SAY-5:fix/download-client-url-base-369

Conversation

@SAY-5
Copy link
Copy Markdown
Contributor

@SAY-5 SAY-5 commented Apr 23, 2026

Summary

Every downloader client (qbittorrent, transmission, deluge, nzbget, sabnzbd) built its connection URL from host:port only. The url_base column is read from the DB into DownloadClient.URLBase but never interpolated into the URL, so operators running an *arr-compatible client behind a reverse-proxy subpath (e.g. Host 192.168.1.10:8080, URL Base /qbit) saw Bindery connect to http://192.168.1.10:8080/api/... instead of http://192.168.1.10:8080/qbit/api/....

Fix

  • New internal/downloader/urlbase helper that normalises user input: trims whitespace, enforces a single leading slash, strips trailing slashes, and tolerates a pasted full URL by keeping only the path segment.
  • Thread a urlBase parameter through each client's New constructor and apply the normalised prefix to baseURL / Transmission's RPC Path.
  • Update every call site in internal/downloader/adapter.go and internal/importer/scanner.go to pass client.URLBase.
  • Update all in-package test helpers so the signature changes stay compile-clean.
  • Empty / whitespace url_base collapses to "", preserving the pre-Download client ignores url_base field — reverse proxy subpath not applied #369 URL shape for deployments without a proxy.

Fixes #369

Test plan

  • go build ./...
  • go test ./... — full suite green, including the existing per-client tests (deluge / nzbget / qbittorrent / sabnzbd / transmission) and the new internal/downloader/urlbase table-test
  • Manually traced each New call site in adapter.go and scanner.go to confirm client.URLBase is wired in

…#369)

Every downloader client (qbittorrent, transmission, deluge, nzbget,
sabnzbd) built its connection URL from host:port only. The
url_base column is read from the DB into DownloadClient.URLBase
but was never interpolated into the URL, so operators running an
*arr-compatible client behind a reverse-proxy subpath (e.g. Host
`192.168.1.10:8080`, URL Base `/qbit`) saw Bindery connect to
http://192.168.1.10:8080/api/... instead of
http://192.168.1.10:8080/qbit/api/...

Add an internal helper `internal/downloader/urlbase` that
normalises user input (trims whitespace, enforces a single leading
slash, strips trailing slashes, tolerates a pasted full URL by
keeping only the path). Thread `urlBase` through each client's
New constructor and apply the normalised prefix to `baseURL` /
Transmission's RPC `Path`. Every call site in `internal/downloader/adapter.go`
and `internal/importer/scanner.go` now passes `client.URLBase`.

Empty / whitespace url_base collapses to "" so existing deployments
without a proxy continue to connect with the historical URL shape.

Fixes vavallee#369

Signed-off-by: SAY-5 <say.apm35@gmail.com>
Copy link
Copy Markdown
Owner

@vavallee vavallee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean implementation — dedicated urlbase package is the right call, and the paste-full-URL normalisation is a nice UX touch that the other approach missed. All checks look good on our side; approving to trigger CI.

@vavallee vavallee merged commit 11f2812 into vavallee:main Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Download client ignores url_base field — reverse proxy subpath not applied

2 participants