Construct Lingva URL using url-join

1a16957519f75b5eab2ae08dbe5ae422a7c48dc5

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +2 -1Showing whitespace changes
src/endpoints/translate.js+2 -1
@@ -4,6 +4,7 @@ import fetch from 'node-fetch';
4import express from 'express';4import express from 'express';
5import { translate as bingTranslate } from 'bing-translate-api';5import { translate as bingTranslate } from 'bing-translate-api';
6import iconv from 'iconv-lite';6import iconv from 'iconv-lite';
7import urlJoin from 'url-join';
78
8import { readSecret, SECRET_KEYS } from './secrets.js';9import { readSecret, SECRET_KEYS } from './secrets.js';
9import { getConfigValue, uuidv4 } from '../util.js';10import { getConfigValue, uuidv4 } from '../util.js';
@@ -220,7 +221,7 @@ router.post('/lingva', jsonParser, async (request, response) => {
220 console.log('Input text: ' + text);221 console.log('Input text: ' + text);
221222
222 try {223 try {
223 const url = `${baseUrl}/auto/${lang}/${encodeURIComponent(text)}`;224 const url = urlJoin(baseUrl, 'auto', lang, encodeURIComponent(text));
224 const result = await fetch(url);225 const result = await fetch(url);
225226
226 if (!result.ok) {227 if (!result.ok) {