refactor: Update bilibili URL regex pattern

This commit is contained in:
Peifan Li
2025-03-09 18:37:46 -04:00
parent 959c54b6f2
commit bbdc78d813

View File

@@ -49,9 +49,9 @@ function isBilibiliUrl(url) {
// Helper function to trim Bilibili URL by removing query parameters
function trimBilibiliUrl(url) {
try {
// Extract the base URL and video ID
// Extract the base URL and video ID - support both desktop and mobile URLs
const regex =
/(https?:\/\/(?:www\.)?bilibili\.com\/video\/(?:BV[\w]+|av\d+))/i;
/(https?:\/\/(?:www\.|m\.)?bilibili\.com\/video\/(?:BV[\w]+|av\d+))/i;
const match = url.match(regex);
if (match && match[1]) {