@careflair/common 1.0.28 → 1.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/utils/video.d.ts +1 -1
- package/dist/utils/video.js +12 -6
- package/package.json +1 -1
package/dist/utils/video.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export interface VideoValidationResult {
|
|
|
13
13
|
export declare function validateVideoLink(url: string, allowedProviders: VideoProvider[]): VideoValidationResult;
|
|
14
14
|
/**
|
|
15
15
|
* Extract YouTube video ID from various URL formats
|
|
16
|
-
* Handles: youtube.com, m.youtube.com, youtu.be, /embed, /v, etc.
|
|
16
|
+
* Handles: youtube.com, m.youtube.com, youtu.be, /embed, /v, /shorts, etc.
|
|
17
17
|
*/
|
|
18
18
|
export declare function extractYouTubeVideoId(url: string): string | null;
|
|
19
19
|
/**
|
package/dist/utils/video.js
CHANGED
|
@@ -38,7 +38,7 @@ function validateVideoLink(url, allowedProviders) {
|
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* Extract YouTube video ID from various URL formats
|
|
41
|
-
* Handles: youtube.com, m.youtube.com, youtu.be, /embed, /v, etc.
|
|
41
|
+
* Handles: youtube.com, m.youtube.com, youtu.be, /embed, /v, /shorts, etc.
|
|
42
42
|
*/
|
|
43
43
|
function extractYouTubeVideoId(url) {
|
|
44
44
|
if (!url)
|
|
@@ -46,25 +46,30 @@ function extractYouTubeVideoId(url) {
|
|
|
46
46
|
const trimmed = url.trim();
|
|
47
47
|
let videoId = null;
|
|
48
48
|
// Handle youtu.be/VIDEO_ID
|
|
49
|
-
if (trimmed.includes(
|
|
49
|
+
if (trimmed.includes("youtu.be/")) {
|
|
50
50
|
const match = trimmed.match(/youtu\.be\/([a-zA-Z0-9_-]{11})/);
|
|
51
51
|
videoId = match ? match[1] : null;
|
|
52
52
|
}
|
|
53
53
|
// Handle youtube.com/watch?v=VIDEO_ID (works for www, m, etc.)
|
|
54
|
-
else if (trimmed.includes(
|
|
54
|
+
else if (trimmed.includes("youtube.com/watch")) {
|
|
55
55
|
const match = trimmed.match(/[?&]v=([a-zA-Z0-9_-]{11})/);
|
|
56
56
|
videoId = match ? match[1] : null;
|
|
57
57
|
}
|
|
58
58
|
// Handle youtube.com/embed/VIDEO_ID
|
|
59
|
-
else if (trimmed.includes(
|
|
59
|
+
else if (trimmed.includes("youtube.com/embed/")) {
|
|
60
60
|
const match = trimmed.match(/\/embed\/([a-zA-Z0-9_-]{11})/);
|
|
61
61
|
videoId = match ? match[1] : null;
|
|
62
62
|
}
|
|
63
63
|
// Handle youtube.com/v/VIDEO_ID
|
|
64
|
-
else if (trimmed.includes(
|
|
64
|
+
else if (trimmed.includes("youtube.com/v/")) {
|
|
65
65
|
const match = trimmed.match(/\/v\/([a-zA-Z0-9_-]{11})/);
|
|
66
66
|
videoId = match ? match[1] : null;
|
|
67
67
|
}
|
|
68
|
+
// Handle youtube.com/shorts/VIDEO_ID
|
|
69
|
+
else if (trimmed.includes("youtube.com/shorts/")) {
|
|
70
|
+
const match = trimmed.match(/\/shorts\/([a-zA-Z0-9_-]{11})/);
|
|
71
|
+
videoId = match ? match[1] : null;
|
|
72
|
+
}
|
|
68
73
|
return videoId;
|
|
69
74
|
}
|
|
70
75
|
/**
|
|
@@ -81,7 +86,8 @@ function detectVideoProvider(url) {
|
|
|
81
86
|
if (!url)
|
|
82
87
|
return null;
|
|
83
88
|
const lower = url.toLowerCase();
|
|
84
|
-
if ((lower.includes("youtube.com") || lower.includes("youtu.be")) &&
|
|
89
|
+
if ((lower.includes("youtube.com") || lower.includes("youtu.be")) &&
|
|
90
|
+
extractYouTubeVideoId(url)) {
|
|
85
91
|
return "youtube";
|
|
86
92
|
}
|
|
87
93
|
if (lower.includes("vimeo.com"))
|