feat: move encodeURIComponent to routes

This commit is contained in:
DIYgod
2019-08-18 18:03:41 +08:00
parent 69c81d8b55
commit 6f2ee73073
2 changed files with 1 additions and 10 deletions

View File

@@ -38,15 +38,6 @@ const custom = got.extend({
options.query = options.query || queryString.stringify(options.params);
}
if (options.query) {
if (typeof options.query === 'string') {
options.query = options.query.replace(/([\u4e00-\u9fa5])/g, (str) => encodeURIComponent(str));
} else if (typeof options.query === 'object') {
for (const key in options.query) {
if (typeof options.query[key] === 'string') {
options.query[key] = options.query[key].replace(/([\u4e00-\u9fa5])/g, (str) => encodeURIComponent(str));
}
}
}
options.searchParams = options.query; // for Got v11 after
}
},