feat: move encodeURIComponent to routes
This commit is contained in:
parent
69c81d8b55
commit
6f2ee73073
|
|
@ -12,7 +12,7 @@ module.exports = async (ctx) => {
|
|||
});
|
||||
const query = `${params.toString()}&${advance}`;
|
||||
const res = await got.get(link, {
|
||||
query: query,
|
||||
query: query.replace(/([\u4e00-\u9fa5])/g, (str) => encodeURIComponent(str)),
|
||||
});
|
||||
const $list = cheerio.load(res.data);
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue