feat: url 支持 credentials; 修改导出文件名格式

This commit is contained in:
xream
2025-03-13 17:37:40 +08:00
parent 312caa6880
commit 47307716b2
6 changed files with 52 additions and 25 deletions

View File

@@ -373,6 +373,17 @@ export function HTTP(defaultOptions = { baseURL: '' }) {
headersTimeout: opts.timeout,
};
try {
const url = new URL(opts.url);
if (url.username || url.password) {
opts.headers = {
...(opts.headers || {}),
Authorization: `Basic ${Buffer.from(
`${url.username || ''}:${
url.password || ''
}`,
).toString('base64')}`,
};
}
const response = await request(opts.url, {
...opts,
method: method.toUpperCase(),