wuyi před 2 měsíci
rodič
revize
99b8362e57
1 změnil soubory, kde provedl 2 přidání a 7 odebrání
  1. 2 7
      src/components/VideoJSPlayer.vue

+ 2 - 7
src/components/VideoJSPlayer.vue

@@ -125,12 +125,7 @@ const setupXHRInterceptor = (): void => {
   ) {
     // 如果是 .m3u8 文件的 Range 请求头,则跳过
     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 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;
     
     // 如果是 .m3u8 文件,移除 Range 请求头
-    if (url && url.endsWith(".m3u8")) {
+    if (url && /\.m3u8(\?|$)/i.test(url)) {
       const modifiedInit = { ...init };
       if (modifiedInit.headers) {
         const headers = new Headers(modifiedInit.headers);