Change url escaping

This commit is contained in:
Gres 2020-04-03 18:38:59 +03:00
parent 45e12265c1
commit ca99f570f7
6 changed files with 9 additions and 12 deletions

View File

@ -30,9 +30,9 @@ function translate(text, from, to) {
return;
}
let url = 'https://www.bing.com/translator/?from=auto&to=' + to + '&text=' + text;
let url = 'https://www.bing.com/translator/?from=auto&to=' + to + '&text=' + encodeURIComponent(text);
console.log("setting url", url);
window.location = encodeURI(url);
window.location = url;
}

View File

@ -42,10 +42,9 @@ function translate(text, from, to) {
return;
}
let url = 'https://www.deepl.com/translator#' + langs +
text.replace('\n', ' ').replace('|', '');
let url = 'https://www.deepl.com/translator#' + langs + encodeURIComponent(text);
console.log("setting url", url);
window.location = encodeURI(url);
window.location = url;
}
function init() {

View File

@ -29,9 +29,9 @@ function translate(text, from, to) {
return;
}
// let url = 'https://translate.google.com/#auto/' + to + '/' + text;
let url = 'https://translate.google.com/#view=home&op=translate&sl=auto&tl=' + to + '&text=' + text;
let url = 'https://translate.google.com/#view=home&op=translate&sl=auto&tl=' + to + '&text=' + encodeURIComponent(text);
console.log("setting url", url);
window.location = encodeURI(url);
window.location = url;
}

View File

@ -11,7 +11,7 @@ function httpGetAsync(url, callback) {
function translate(text, from, to) {
console.log('start translate', text, from, to)
let url = 'https://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl=' + to + '&dt=t&q=' + text;
let url = 'https://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl=' + to + '&dt=t&q=' + encodeURIComponent(text);
console.log("loading url", url);
httpGetAsync(url, function (response) {

View File

@ -54,8 +54,7 @@ function translate(text, from, to) {
return;
}
let url = 'https://papago.naver.com/?sk=auto&tk=' + to + '&st=' +
text.replace("\n", " ");
let url = 'https://papago.naver.com/?sk=auto&tk=' + to + '&st=' + encodeURIComponent(text);
window.location = encodeURI(url);
}

View File

@ -32,8 +32,7 @@ function translate(text, from, to) {
return;
}
let url = 'https://translate.yandex.ru/?' + langs + '&text=' + text;
url = url.replace(new RegExp(' ', 'g'), '%20')
let url = 'https://translate.yandex.ru/?' + langs + '&text=' + encodeURIComponent(text);
console.log("setting url", url);
window.location = url;
}