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. */ /** Translation provider used to translate posts. */
static get translationProvider(): string | undefined { static get translationProvider(): string | undefined {
return Deno.env.get('TRANSLATION_PROVIDER')?.toLowerCase(); return Deno.env.get('TRANSLATION_PROVIDER');
} }
/** Translation provider URL endpoint. */ /** Translation provider URL endpoint. */
static get translationProviderEndpoint(): string | undefined { static get translationProviderEndpoint(): string | undefined {

View file

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

View file

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

View file

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