Skip to content

URL-encode download URL to fix items with spaces in archive filename#8

Merged
rmgpanw merged 1 commit into
mainfrom
fix/url-encode-download-url
Mar 16, 2026
Merged

URL-encode download URL to fix items with spaces in archive filename#8
rmgpanw merged 1 commit into
mainfrom
fix/url-encode-download-url

Conversation

@rmgpanw

@rmgpanw rmgpanw commented Mar 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #7.

  • download_item() fails for TRUD items whose archive filename contains spaces (e.g. OPCS-4, item 119: "OPCS-4.11 Data files txt.zip")
  • The URL retrieved from the TRUD API is passed directly to httr2::request() without encoding, causing curl::curl_parse_url() to reject the spaces
  • Fix: URL-encode the URL with utils::URLencode(url, repeated = FALSE) before passing to request_download_item()
  • repeated = FALSE ensures only unencoded characters are encoded (spaces → %20), leaving already-encoded sequences intact

Test plan

  • All 41 existing tests pass (devtools::test())
  • Manual test with TRUD item 119 (OPCS-4) once PR is merged

🤖 Generated with Claude Code

trud items whose archive filename contains spaces (e.g. OPCS-4, item 119:
"OPCS-4.11 Data files txt.zip") fail because the unencoded URL is passed
directly to httr2::request() / curl::curl_parse_url(), which rejects spaces
in the host/path.

Fixes #7

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@rmgpanw rmgpanw merged commit 19ea29c into main Mar 16, 2026
10 checks passed
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_item() fails for items with spaces in archive filename (e.g. OPCS-4, item 119)

1 participant