Initial commit: KOC LOOP platform

This commit is contained in:
巫凤萍
2026-07-30 12:06:41 +08:00
commit d2cde2c9b2
98 changed files with 44076 additions and 0 deletions

29
lib/partner-utils.ts Normal file
View File

@@ -0,0 +1,29 @@
import { hashText } from "./mvp-db";
import {
extractXhsPublishUrl,
safeHttpUrl,
} from "./publish-url";
export { extractXhsPublishUrl } from "./publish-url";
export function accountFromPublishLink(input: string, nickname: string) {
const url = safeHttpUrl(extractXhsPublishUrl(input));
if (!url) return null;
const platform =
url.hostname.includes("xiaohongshu") || url.hostname.includes("xhslink")
? "小红书"
: "其他平台";
const noteId =
url.pathname.match(
/\/(?:discovery\/item|explore)\/([A-Za-z0-9_-]{8,80})/,
)?.[1] ?? "";
const platformUid = `pending-${hashText(
noteId || `${url.origin}${url.pathname}`,
)}`;
return {
platform,
platformUid,
nickname,
profileUrl: "",
};
}