|
@@ -125,12 +125,7 @@ const setupXHRInterceptor = (): void => {
|
|
|
) {
|
|
) {
|
|
|
// 如果是 .m3u8 文件的 Range 请求头,则跳过
|
|
// 如果是 .m3u8 文件的 Range 请求头,则跳过
|
|
|
const url = (this as any)._url || "";
|
|
const url = (this as any)._url || "";
|
|
|
- if (
|
|
|
|
|
- url &&
|
|
|
|
|
- typeof url === "string" &&
|
|
|
|
|
- url.endsWith(".m3u8") &&
|
|
|
|
|
- header.toLowerCase() === "range"
|
|
|
|
|
- ) {
|
|
|
|
|
|
|
+ if (url && /\.m3u8(\?|$)/i.test(url) && header.toLowerCase() === "range") {
|
|
|
return; // 不设置 Range 请求头
|
|
return; // 不设置 Range 请求头
|
|
|
}
|
|
}
|
|
|
return originalXHRSetRequestHeader.apply(this, [header, value]);
|
|
return originalXHRSetRequestHeader.apply(this, [header, value]);
|
|
@@ -144,7 +139,7 @@ const setupXHRInterceptor = (): void => {
|
|
|
const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
|
|
const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
|
|
|
|
|
|
|
|
// 如果是 .m3u8 文件,移除 Range 请求头
|
|
// 如果是 .m3u8 文件,移除 Range 请求头
|
|
|
- if (url && url.endsWith(".m3u8")) {
|
|
|
|
|
|
|
+ if (url && /\.m3u8(\?|$)/i.test(url)) {
|
|
|
const modifiedInit = { ...init };
|
|
const modifiedInit = { ...init };
|
|
|
if (modifiedInit.headers) {
|
|
if (modifiedInit.headers) {
|
|
|
const headers = new Headers(modifiedInit.headers);
|
|
const headers = new Headers(modifiedInit.headers);
|