Update m3u8-utils.ts

This commit is contained in:
Troray
2026-01-19 22:32:39 +08:00
parent 47e8df2c6a
commit 140b39ecf7
+2 -7
View File
@@ -22,13 +22,8 @@ export type AdFilterMode = 'off' | 'keyword' | 'heuristic' | 'aggressive';
export function filterM3u8Ad(content: string, baseUrl: string, mode: AdFilterMode = 'heuristic', customKeywords: string[] = []): string {
if (!content) return '';
// 1. Performance: Parse Keywords & Base URL ONLY ONCE
// Merge env keywords (build time) with custom keywords (runtime injected)
const envKeywordsStr = process.env.NEXT_PUBLIC_AD_KEYWORDS || '';
const envKeywords = envKeywordsStr.split(/[\n,]/).map(k => k.trim()).filter(k => k);
// Combine and deduplicate
const keywords = Array.from(new Set([...envKeywords, ...customKeywords]));
// Use keywords passed from AdKeywordsWrapper (already loaded from env/file)
const keywords = customKeywords;
const basePath = baseUrl.substring(0, baseUrl.lastIndexOf('/') + 1);
let origin = '';