@careflair/common 1.0.25 → 1.0.26

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.
@@ -10,7 +10,7 @@ export interface VideoValidationResult {
10
10
  export declare function validateVideoLink(url: string, allowedProviders: VideoProvider[]): VideoValidationResult;
11
11
  /**
12
12
  * Extract YouTube video ID from various URL formats
13
- * Handles: youtube.com, m.youtube.com, youtu.be, /embed, /v, etc.
13
+ * Handles: youtube.com, m.youtube.com, youtu.be, /embed, /v, /shorts, etc.
14
14
  */
15
15
  export declare function extractYouTubeVideoId(url: string): string | null;
16
16
  /**
@@ -30,7 +30,7 @@ function validateVideoLink(url, allowedProviders) {
30
30
  }
31
31
  /**
32
32
  * Extract YouTube video ID from various URL formats
33
- * Handles: youtube.com, m.youtube.com, youtu.be, /embed, /v, etc.
33
+ * Handles: youtube.com, m.youtube.com, youtu.be, /embed, /v, /shorts, etc.
34
34
  */
35
35
  function extractYouTubeVideoId(url) {
36
36
  if (!url)
@@ -38,22 +38,27 @@ function extractYouTubeVideoId(url) {
38
38
  const trimmed = url.trim();
39
39
  let videoId = null;
40
40
  // Handle youtu.be/VIDEO_ID
41
- if (trimmed.includes('youtu.be/')) {
41
+ if (trimmed.includes("youtu.be/")) {
42
42
  const match = trimmed.match(/youtu\.be\/([a-zA-Z0-9_-]{11})/);
43
43
  videoId = match ? match[1] : null;
44
44
  }
45
45
  // Handle youtube.com/watch?v=VIDEO_ID (works for www, m, etc.)
46
- else if (trimmed.includes('youtube.com/watch')) {
46
+ else if (trimmed.includes("youtube.com/watch")) {
47
47
  const match = trimmed.match(/[?&]v=([a-zA-Z0-9_-]{11})/);
48
48
  videoId = match ? match[1] : null;
49
49
  }
50
+ // Handle youtube.com/shorts/VIDEO_ID
51
+ else if (trimmed.includes("youtube.com/shorts/")) {
52
+ const match = trimmed.match(/\/shorts\/([a-zA-Z0-9_-]{11})/);
53
+ videoId = match ? match[1] : null;
54
+ }
50
55
  // Handle youtube.com/embed/VIDEO_ID
51
- else if (trimmed.includes('youtube.com/embed/')) {
56
+ else if (trimmed.includes("youtube.com/embed/")) {
52
57
  const match = trimmed.match(/\/embed\/([a-zA-Z0-9_-]{11})/);
53
58
  videoId = match ? match[1] : null;
54
59
  }
55
60
  // Handle youtube.com/v/VIDEO_ID
56
- else if (trimmed.includes('youtube.com/v/')) {
61
+ else if (trimmed.includes("youtube.com/v/")) {
57
62
  const match = trimmed.match(/\/v\/([a-zA-Z0-9_-]{11})/);
58
63
  videoId = match ? match[1] : null;
59
64
  }
@@ -73,7 +78,8 @@ function detectVideoProvider(url) {
73
78
  if (!url)
74
79
  return null;
75
80
  const lower = url.toLowerCase();
76
- if ((lower.includes("youtube.com") || lower.includes("youtu.be")) && extractYouTubeVideoId(url)) {
81
+ if ((lower.includes("youtube.com") || lower.includes("youtu.be")) &&
82
+ extractYouTubeVideoId(url)) {
77
83
  return "youtube";
78
84
  }
79
85
  if (lower.includes("vimeo.com"))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@careflair/common",
3
- "version": "1.0.25",
3
+ "version": "1.0.26",
4
4
  "description": "Shared assets for CareFlair",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",