Hot fix for Surge HTTP 2.0 feature

This commit is contained in:
Peng-YM 2022-06-14 23:52:04 +08:00
parent 97de476ae3
commit 051a01efb0
3 changed files with 13 additions and 4 deletions

View File

@ -6,7 +6,7 @@
* *
* *
* Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket! * Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket!
* @updated: 2022/6/13 14:20:20 * @updated: 2022/6/14 23:51:44
* @version: 1.6 * @version: 1.6
* @author: Peng-YM * @author: Peng-YM
* @github: https://github.com/Peng-YM/Sub-Store * @github: https://github.com/Peng-YM/Sub-Store

View File

@ -54,7 +54,8 @@ export default function express({ substore: $, port }) {
// dispatch url to route // dispatch url to route
const dispatch = (request, start = 0) => { const dispatch = (request, start = 0) => {
let { method, url, headers, body } = request; let { method, url, headers, body } = request;
if (/json/i.test(headers['Content-Type'])) { headers = formatHeaders(headers);
if (/json/i.test(headers['content-type'])) {
body = JSON.parse(body); body = JSON.parse(body);
} }
@ -214,6 +215,14 @@ export default function express({ substore: $, port }) {
} }
} }
function formatHeaders(headers) {
const result = {};
for (const k of Object.keys(headers)) {
result[k.toLowerCase()] = headers[k];
}
return result;
}
function patternMatched(pattern, path) { function patternMatched(pattern, path) {
if (pattern instanceof RegExp && pattern.test(path)) { if (pattern instanceof RegExp && pattern.test(path)) {
return true; return true;

File diff suppressed because one or more lines are too long