Skip to content

Keep the case of custom API URLs (translate, TTS, STT) - #1207

Merged
jianchang512 merged 1 commit into
jianchang512:mainfrom
Dev-next-gen:fix/custom-api-url-case
Sep 14, 2026
Merged

jianchang512 merged 1 commit into
jianchang512:mainfrom
Dev-next-gen:fix/custom-api-url-case

Conversation

@Dev-next-gen

Copy link
Copy Markdown
Contributor

While reading 9a256da I noticed that the custom recognition API (_recognapi.py) stopped lowercasing the URL the user types, and now only compares the scheme case-insensitively. Three sibling channels still have the old line:

  • videotrans/translator/_transapi.py (trans_api_url)
  • videotrans/tts/_ttsapi.py (ttsapi_url)
  • videotrans/recognition/_stt.py (stt_url)

Each one does .strip().rstrip('/').lower() on the whole address, so a case-sensitive path or a token in the query string is sent altered. For example https://example.com/Translate?token=AbC becomes https://example.com/translate?token=abc, and _transapi.py explicitly supports a ? in the URL, which is where a key usually goes.

I applied the same change as in _recognapi.py: the URL keeps its case, and only the http check (plus the /api suffix check in _stt.py) uses .lower(), so HTTP://... and .../API are still recognised as before.

I added tests/test_custom_api_url.py, which builds each channel from params and checks api_url. On main, 5 of the 6 tests fail with the lowercased URL, and all 6 pass with this change. On the rest of the suite, the before/after runs differ by exactly those 5 tests. I ran it without the GUI dependencies, so some unrelated tests fail in both runs.

AI tools used

The custom translation, TTS and STT channels lowercased the whole URL the user typed, so a case-sensitive path or a token in the query string was sent altered. Only compare the scheme and the /api suffix case-insensitively, as recognapi already does since 9a256da.
@jianchang512
jianchang512 merged commit 253a837 into jianchang512:main Sep 14, 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.

2 participants