refactor: make provider lowercase because supporting case insensitive is allegedly protocol bloat

This commit is contained in:
P. Reis 2024-10-07 17:54:03 -03:00
parent 4712cb1d80
commit bfab84d937
4 changed files with 5 additions and 5 deletions

View file

@ -273,7 +273,7 @@ class Conf {
}
/** Translation provider used to translate posts. */
static get translationProvider(): string | undefined {
return Deno.env.get('TRANSLATION_PROVIDER')?.toLowerCase();
return Deno.env.get('TRANSLATION_PROVIDER');
}
/** Translation provider URL endpoint. */
static get translationProviderEndpoint(): string | undefined {

View file

@ -11,7 +11,7 @@ export const translatorMiddleware: AppMiddleware = async (c, next) => {
const translationProvider = Conf.translationProvider;
switch (translationProvider) {
case 'DeepL'.toLowerCase():
case 'deepl':
if (apiKey) {
c.set(
'translator',
@ -19,7 +19,7 @@ export const translatorMiddleware: AppMiddleware = async (c, next) => {
);
}
break;
case 'Libretranslate'.toLowerCase():
case 'libretranslate':
if (apiKey) {
c.set(
'translator',

View file

@ -7,7 +7,7 @@ import { getLanguage } from '@/test.ts';
const endpoint = Conf.translationProviderEndpoint;
const apiKey = Conf.translationProviderApiKey;
const translationProvider = Conf.translationProvider;
const deepL = 'DeepL'.toLowerCase();
const deepL = 'deepl';
Deno.test('Translate status with EMPTY media_attachments and WITHOUT poll', {
ignore: !(translationProvider === deepL && apiKey),

View file

@ -7,7 +7,7 @@ import { getLanguage } from '@/test.ts';
const endpoint = Conf.translationProviderEndpoint;
const apiKey = Conf.translationProviderApiKey;
const translationProvider = Conf.translationProvider;
const libreTranslate = 'Libretranslate'.toLowerCase();
const libreTranslate = 'libretranslate';
Deno.test('Translate status with EMPTY media_attachments and WITHOUT poll', {
ignore: !(translationProvider === libreTranslate && apiKey),