fix(bilibili): read the page query from the pasted video link

This commit is contained in:
TIANYAO ZHANG committed 2026-11-18 16:40:27 +08:00
1 parent b7779ab108
commit 79e9cd797c
2 files changed
+5 -3

No files matched your search

+3 -3
View File
@@ -69,9 +69,9 @@ export function parseSongRef(raw: string): SongRef | null {
// a "BV..." token never collides with them).
const bv = /BV[0-9A-Za-z]{8,12}/.exec(q);
if (bv && (/^BV[0-9A-Za-z]{8,12}$/.test(q) || /bilibili\.com|b23\.tv/i.test(q))) {
// TeamSpeak wraps pasted links in [URL] tags. Keep the page query while
// ignoring fragments, which can contain unrelated player state.
const query = /\?(.*)$/.exec(stripUrlBBCode(q).trim().split("#", 1)[0])?.[1];
// Extract the query attached to this BV id, including in [URL=...] tags.
const suffix = q.slice(bv.index + bv[0].length);
const query = /^\/?\?([^#\s[\]]*)/.exec(suffix)?.[1];
const page = new URLSearchParams(query).get("p");
return { id: page && /^\d+$/.test(page) ? `${bv[0]}?p=${page}` : bv[0], platform: "bilibili" };
}