Skip to content

Commit 8a28a9c

Browse files
committed
fix: unsafe header覆盖失败
1 parent 0375282 commit 8a28a9c

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/apps/grant/background.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ export class BackgroundGrant {
6464
let requestHeaders: chrome.webRequest.HttpHeader[] = [];
6565
let unsafeHeader: { [key: string]: string } = {};
6666
data.requestHeaders?.forEach((val, key) => {
67-
switch (val.name.toLowerCase()) {
67+
let lowerCase = val.name.toLowerCase();
68+
switch (lowerCase) {
6869
case "x-cat-" + this.rand + "-cookie": {
6970
setCookie = val.value || '';
7071
break;
@@ -79,7 +80,7 @@ export class BackgroundGrant {
7980
case "x-cat-" + this.rand + "-origin":
8081
case "x-cat-" + this.rand + "-accept-encoding":
8182
case "x-cat-" + this.rand + "-connection": {
82-
unsafeHeader[val.name.substr(("x-cat-" + this.rand).length + 1)] = val.value || '';
83+
unsafeHeader[lowerCase.substr(this.rand.length + 7)] = val.value || '';
8384
break;
8485
}
8586
case "cookie": {
@@ -90,8 +91,10 @@ export class BackgroundGrant {
9091
case "host":
9192
case "origin":
9293
case "referer":
94+
case "accept-encoding":
95+
case "connection":
9396
{
94-
unsafeHeader[val.name] = unsafeHeader[val.name] || val.value || '';
97+
unsafeHeader[lowerCase] = unsafeHeader[lowerCase] || val.value || '';
9598
break
9699
}
97100
default: {

0 commit comments

Comments
 (0)