Fix uuidv4 on Node 18 Closes #2718
| @@ -110,6 +110,7 @@ router.post('/google', jsonParser, async (request, response) => { | ||
| 110 | 110 | }); |
| 111 | 111 | |
| 112 | 112 | router.post('/yandex', jsonParser, async (request, response) => { |
| 113 | + try { | |
| 113 | 114 | const chunks = request.body.chunks; |
| 114 | 115 | const lang = request.body.lang; |
| 115 | 116 | |
| @@ -130,7 +131,6 @@ router.post('/yandex', jsonParser, async (request, response) => { | ||
| 130 | 131 | |
| 131 | 132 | console.log('Input text: ' + inputText); |
| 132 | 133 | |
| 133 | - try { | |
| 134 | 134 | const result = await fetch(`https://translate.yandex.net/api/v1/tr.json/translate?ucid=${ucid}&srv=android&format=text`, { |
| 135 | 135 | method: 'POST', |
| 136 | 136 | body: params, |
| @@ -299,8 +299,8 @@ const color = { | ||
| 299 | 299 | * @returns {string} A UUIDv4 string |
| 300 | 300 | */ |
| 301 | 301 | function uuidv4() { |
| 302 | 302 | if ('crypto' in global && 'randomUUID' in global.crypto) { |
| 303 | 303 | return global.crypto.randomUUID(); |
| 304 | 304 | } |
| 305 | 305 | return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { |
| 306 | 306 | const r = Math.random() * 16 | 0; |