mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-07 21:47:57 +08:00
feat: move encodeURIComponent to routes
This commit is contained in:
@@ -12,7 +12,7 @@ module.exports = async (ctx) => {
|
|||||||
});
|
});
|
||||||
const query = `${params.toString()}&${advance}`;
|
const query = `${params.toString()}&${advance}`;
|
||||||
const res = await got.get(link, {
|
const res = await got.get(link, {
|
||||||
query: query,
|
query: query.replace(/([\u4e00-\u9fa5])/g, (str) => encodeURIComponent(str)),
|
||||||
});
|
});
|
||||||
const $list = cheerio.load(res.data);
|
const $list = cheerio.load(res.data);
|
||||||
|
|
||||||
|
|||||||
@@ -38,15 +38,6 @@ const custom = got.extend({
|
|||||||
options.query = options.query || queryString.stringify(options.params);
|
options.query = options.query || queryString.stringify(options.params);
|
||||||
}
|
}
|
||||||
if (options.query) {
|
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
|
options.searchParams = options.query; // for Got v11 after
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user