29 lines
644 B
TypeScript
29 lines
644 B
TypeScript
import type { AfterSearchRateField } from "./result-types";
|
||
|
||
function normalizeText(value: string): string {
|
||
return value
|
||
.trim()
|
||
.replace(/\s+/g, "")
|
||
.replace(/[::,,。.()()\-]/g, "")
|
||
.toLowerCase();
|
||
}
|
||
|
||
export function normalizeRateLabel(
|
||
label: string
|
||
): AfterSearchRateField | null {
|
||
const normalized = normalizeText(label);
|
||
|
||
if (normalized.includes("个人视频看后搜率")) {
|
||
return "personalVideoAfterSearchRate";
|
||
}
|
||
|
||
if (
|
||
normalized.includes("单条视频看后搜率") ||
|
||
normalized.includes("单视频看后搜率")
|
||
) {
|
||
return "singleVideoAfterSearchRate";
|
||
}
|
||
|
||
return null;
|
||
}
|