Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Исправление парсинга заголовков GM_Fetch #1029

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/vot-min.user.js

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions dist/vot.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -2580,17 +2580,18 @@ async function GM_fetch(url, opts = {}) {
timeout,
headers: Object.fromEntries(new Headers(fetchOptions.headers || {})),
onload: (resp) => {
const headers = {};
resp.responseHeaders.trim().split(/\r?\n/).forEach(line => {
const [name, value] = line.split(/:\s*/);
if (name && value) {
headers[name.trim()] = value.trim();
}
});

resolve(
new Response(resp.response, {
status: resp.status,
headers: new Headers(
Object.fromEntries(
resp.responseHeaders
.trim()
.split(/\r?\n/)
.map((line) => line.split(/:\s*/)),
),
),
headers: new Headers(headers),
}),
);
},
Expand Down
20 changes: 12 additions & 8 deletions src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,21 @@ async function GM_fetch(url, opts = {}) {
timeout,
headers: Object.fromEntries(new Headers(fetchOptions.headers || {})),
onload: (resp) => {
const headers = {};
resp.responseHeaders
.trim()
.split(/\r?\n/)
.forEach((line) => {
const [name, value] = line.split(/:\s*/);
if (name && value) {
headers[name.trim()] = value.trim();
}
});

resolve(
new Response(resp.response, {
status: resp.status,
headers: new Headers(
Object.fromEntries(
resp.responseHeaders
.trim()
.split(/\r?\n/)
.map((line) => line.split(/:\s*/)),
),
),
headers: new Headers(headers),
}),
);
},
Expand Down
Loading