feat: free key endpoint resolution and custom/regional URL support#32
Merged
shirgoldbird merged 11 commits intomainfrom Apr 7, 2026
Merged
feat: free key endpoint resolution and custom/regional URL support#32shirgoldbird merged 11 commits intomainfrom
shirgoldbird merged 11 commits intomainfrom
Conversation
… simplify resolver
- Rewrite resolve-endpoint tests from 43 to 25 using table-driven it.each() (covers all 5 priority branches + edge cases: subdomain spoof, URL parsing) - Consolidate free-key-auth-init tests from 5 to 3 (drop redundant InitCommand) - Reduce voice wiring test from 4 to 1 (pin passthrough, not permutations) - Remove 55 expect(true).toBe(true) anti-pattern across integration/e2e tests - Add expect.assertions(N) guards to 10 must-fail tests (API key required, etc.) - Add InitCommand :fx key test to init-command.test.ts (closes coverage gap) Net: 3486 → 3464 tests, zero branch coverage lost, -466 lines of test code. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
sjsyrek
approved these changes
Apr 5, 2026
Six integration tests had no assertions, causing the eslint jest/expect-expect rule to fail in CI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds automatic API endpoint resolution based on key suffix (
:fx→api-free.deepl.com), while preserving custom/regional endpoint support (e.g.api-jp.deepl.com).Closes #30
Changes Made
New shared endpoint resolver (
src/utils/resolve-endpoint.ts) with clear priority chain:--api-urlCLI flag (highest priority)api.baseUrlfrom config (non-standard hostname):fx→ free endpoint, else → pro endpointapi.usePro === falsefallback → free endpointStandard DeepL URLs no longer block auto-detection: persisted
api.baseUrlvalues ofapi.deepl.comorapi-free.deepl.com(with any path) are treated as tier defaults, not custom overrides.Auth and init commands resolve from entered key:
auth set-keyandinitnow validate against the correct endpoint based on the key being entered, not the saved config.Voice API follows the same resolution: removed hardcoded
PRO_API_URLfromVoiceClient; endpoint selection is now centralized in the resolver like all other commands.Exported
FREE_API_URL/PRO_API_URLfromhttp-client.tsfor shared use.Test Coverage
resolveEndpoint(),isStandardDeepLUrl(),isFreeKey():fxtest keys)Backward Compatibility
api.useProconfig key is preserved as a backward-compatible fallback (does not override:fxkey detection)api-jp.deepl.comremain authoritative--api-urltranslate flag still takes highest priority