Skip to content

Commit

Permalink
fix(url): fix hostname bilibili.com not detected
Browse files Browse the repository at this point in the history
  • Loading branch information
aidenlx committed Mar 18, 2024
1 parent 0edd851 commit 2e4dc59
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion apps/app/src/web/url-match/bilibili.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ function parseVideoId(url: URL): string | false | null {
// short url don't have vid in url
return false;
}
if (!url.hostname.endsWith(".bilibili.com")) {
if (
url.hostname !== "bilibili.com" &&
!url.hostname.endsWith(".bilibili.com")
) {
return null;
}
if (
Expand Down Expand Up @@ -41,6 +44,9 @@ export const bilibiliResolver: URLResolver = (url) => {
const time = parseTimeFromBilibiliUrl(url);

const cleaned = noHashUrl(url);
if (cleaned.hostname === "bilibili.com") {
cleaned.hostname = "www.bilibili.com";
}
cleaned.searchParams.forEach((val, key, params) => {
if (key === "p" && val !== "1") return;
params.delete(key);
Expand Down

0 comments on commit 2e4dc59

Please sign in to comment.