You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
1007 B
29 lines
1007 B
/**
|
|
* 客户可见文案脱敏:隐藏上游报价源品牌,避免终端用户自行比价。
|
|
* 内部代码/日志/管理端标识仍可用 mothership 命名,仅 scrub 对外展示字符串。
|
|
*/
|
|
|
|
const PROVIDER_BRAND_RE =
|
|
/\bMother\s*Ship\b|\bMothership\b|mothership\.com/gi;
|
|
|
|
/** 承运商名整段命中品牌时的展示替换 */
|
|
export function scrubProviderCarrierLabel(carrier: string | null | undefined): string {
|
|
const raw = (carrier ?? "").trim();
|
|
if (!raw) return "承运商";
|
|
if (/^mother\s*ship$/i.test(raw) || /^mothership$/i.test(raw)) {
|
|
return "平台承运";
|
|
}
|
|
return scrubProviderBrandForCustomer(raw);
|
|
}
|
|
|
|
/** 将客户可见文案中的上游品牌替换为中性词 */
|
|
export function scrubProviderBrandForCustomer(text: string): string {
|
|
if (!text) return text;
|
|
return text
|
|
.replace(PROVIDER_BRAND_RE, (match) =>
|
|
/mothership\.com/i.test(match) ? "承运商官网" : "承运商",
|
|
)
|
|
.replace(/承运商\s{2,}/g, "承运商 ")
|
|
.trim();
|
|
}
|