2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-08 17:22:34 +03:00

fix(headers): fixed the filtering logic of the clear method; (#5542)

This commit is contained in:
Dmitriy Mozgovoy
2023-02-11 16:31:03 +02:00
committed by GitHub
parent 0b449293fc
commit ea87ebfe6d
2 changed files with 9 additions and 5 deletions
+6 -2
View File
@@ -33,11 +33,15 @@ function isValidHeaderName(str) {
return /^[-_a-zA-Z]+$/.test(str.trim());
}
function matchHeaderValue(context, value, header, filter) {
function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
if (utils.isFunction(filter)) {
return filter.call(this, value, header);
}
if (isHeaderNameFilter) {
value = header;
}
if (!utils.isString(value)) return;
if (utils.isString(filter)) {
@@ -181,7 +185,7 @@ class AxiosHeaders {
while (i--) {
const key = keys[i];
if(!matcher || matchHeaderValue(this, this[key], key, matcher)) {
if(!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
delete this[key];
deleted = true;
}