fix: honor android sdk mirror url - #10
Conversation
There was a problem hiding this comment.
Code Review
This pull request replaces the custom env module with os.getenv to retrieve the ANDROID_SDK_MIRROR_URL environment variable in both available.lua and pre_install.lua hooks. It also introduces a new test script (test/mirror_url.lua) and integrates it into the test suite (test/run.sh) to verify mirror URL handling. Feedback suggests normalizing the base_url by stripping any trailing slashes to prevent double slashes when constructing URLs.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| local env = require("env") | ||
|
|
||
| local base_url = env.ANDROID_SDK_MIRROR_URL or "https://dl.google.com/android/repository" | ||
| local base_url = os.getenv("ANDROID_SDK_MIRROR_URL") or "https://dl.google.com/android/repository" |
There was a problem hiding this comment.
If the user configures ANDROID_SDK_MIRROR_URL with a trailing slash (e.g., https://mirror.example/android/), appending /repository2-3.xml will result in a URL with double slashes (https://mirror.example/android//repository2-3.xml). Some strict HTTP servers or proxies might reject this or return a 404.
It is safer to normalize the base_url by stripping any trailing slashes.
local base_url = (os.getenv("ANDROID_SDK_MIRROR_URL") or "https://dl.google.com/android/repository"):gsub("/+$", "")
| end | ||
|
|
||
| local base_url = env.ANDROID_SDK_MIRROR_URL or "https://dl.google.com/android/repository" | ||
| local base_url = os.getenv("ANDROID_SDK_MIRROR_URL") or "https://dl.google.com/android/repository" |
There was a problem hiding this comment.
If the user configures ANDROID_SDK_MIRROR_URL with a trailing slash, appending /repository2-3.xml or / followed by the relative URL will result in double slashes. Normalizing the base_url by stripping trailing slashes ensures robust URL construction.
local base_url = (os.getenv("ANDROID_SDK_MIRROR_URL") or "https://dl.google.com/android/repository"):gsub("/+$", "")
Summary
ANDROID_SDK_MIRROR_URLfrom the process environment in both version discovery and pre-install hooksRoot cause
The hooks attempted to read the variable from the vfox
envmodule, where it was alwaysnil. The vfox runtime exposes process environment variables throughos.getenv.Validation
mise x stylua@latest -- stylua --check metadata.lua hooks test/mirror_url.luamise x actionlint@latest -- actionlint .github/workflows/test.ymlmise x lua@5.4 -- ./test/run.shResolves #6.