Skip to content

Commit

Permalink
fix: parseResponseHeaders with empty string return ealier
Browse files Browse the repository at this point in the history
  • Loading branch information
superfreeeee committed Dec 12, 2023
1 parent e6bc59e commit d9343b2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,11 @@ export const data2QueryString = (data: Record<string, any>) => {
* @returns 响应头对象
*/
export const parseResponseHeaders = (headerString: string) => {
const headersAry = headerString.trim().split(/[\r\n]+/);
const headersMap = {} as AlovaXHRResponseHeaders;
if (headerString === '') {
return headersMap;
}
const headersAry = headerString.trim().split(/[\r\n]+/);
headersAry.forEach(line => {
const [headerName, value] = line.split(/:\s*/);
headersMap[headerName] = value;
Expand Down

0 comments on commit d9343b2

Please sign in to comment.