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