@careflair/common 1.0.23 → 1.0.25
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/enums/index.d.ts +14 -0
- package/dist/enums/index.js +17 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -6
- package/dist/utils/video.d.ts +9 -0
- package/dist/utils/video.js +47 -8
- package/dist/utils/videoValidation.d.ts +9 -9
- package/dist/utils/videoValidation.js +49 -68
- package/package.json +1 -1
package/dist/enums/index.d.ts
CHANGED
|
@@ -410,3 +410,17 @@ export declare enum screeningAndChildrenCheckStatus {
|
|
|
410
410
|
DECLINED = "declined",
|
|
411
411
|
EXPIRED = "expired"
|
|
412
412
|
}
|
|
413
|
+
export declare enum PushNotificationType {
|
|
414
|
+
CHAT_MESSAGE = "chat_message",
|
|
415
|
+
ID_VERIFICATION_REMINDER = "id_verification_reminder",
|
|
416
|
+
NDIS_SCREENING_REMINDER = "ndis_screening_reminder",
|
|
417
|
+
WWCC_REMINDER = "wwcc_reminder",
|
|
418
|
+
NEW_JOB_OPPORTUNITY = "new_job_opportunity",
|
|
419
|
+
ID_VERIFICATION_SUCCESS = "id_verification_success",
|
|
420
|
+
ID_VERIFICATION_RESUBMISSION_REQUESTED = "id_verification_resubmission_requested",
|
|
421
|
+
ID_VERIFICATION_DECLINED = "id_verification_declined",
|
|
422
|
+
NDIS_SCREENING_APPROVED = "ndis_screening_approved",
|
|
423
|
+
NDIS_SCREENING_DECLINED = "ndis_screening_declined",
|
|
424
|
+
WWCC_APPROVED = "wwcc_approved",
|
|
425
|
+
WWCC_DECLINED = "wwcc_declined"
|
|
426
|
+
}
|
package/dist/enums/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.screeningAndChildrenCheckStatus = exports.veriffStatuses = exports.ContractTypeEnum = exports.OnboardingSteps = exports.DocumentType = exports.JOB_TABS = exports.BOOKING_ACTIVITY_TYPE = exports.JOB_WORKER_TYPE = exports.SupportWorkerService = exports.AltCommunication = exports.NotificationType = exports.JobScheduleFrequencyEnum = exports.FileContentType = exports.MessageStatus = exports.MessageType = exports.PostUpvoteTypes = exports.PostTypes = exports.CommunityMembersStatuses = exports.AttachmentFilesEnum = exports.ProviderInterestEnum = exports.ProviderPreferenceEnum = exports.ParticipantInterestEnum = exports.ParticipantPreferenceEnum = exports.DaysOfWeek = exports.ProfileAllStepsEnum = exports.BusinessClassTypes = exports.BusinessType = exports.OtpType = exports.UserRole = exports.EducationTypeEnum = exports.ComplexNeedsSupportedEnum = exports.AgesSupportedEnum = exports.GenderOfAttendanceEnum = exports.DeliveryEnum = exports.LanguageEnum = exports.StatesEnum = exports.CategoryEnum = void 0;
|
|
3
|
+
exports.PushNotificationType = exports.screeningAndChildrenCheckStatus = exports.veriffStatuses = exports.ContractTypeEnum = exports.OnboardingSteps = exports.DocumentType = exports.JOB_TABS = exports.BOOKING_ACTIVITY_TYPE = exports.JOB_WORKER_TYPE = exports.SupportWorkerService = exports.AltCommunication = exports.NotificationType = exports.JobScheduleFrequencyEnum = exports.FileContentType = exports.MessageStatus = exports.MessageType = exports.PostUpvoteTypes = exports.PostTypes = exports.CommunityMembersStatuses = exports.AttachmentFilesEnum = exports.ProviderInterestEnum = exports.ProviderPreferenceEnum = exports.ParticipantInterestEnum = exports.ParticipantPreferenceEnum = exports.DaysOfWeek = exports.ProfileAllStepsEnum = exports.BusinessClassTypes = exports.BusinessType = exports.OtpType = exports.UserRole = exports.EducationTypeEnum = exports.ComplexNeedsSupportedEnum = exports.AgesSupportedEnum = exports.GenderOfAttendanceEnum = exports.DeliveryEnum = exports.LanguageEnum = exports.StatesEnum = exports.CategoryEnum = void 0;
|
|
4
4
|
var CategoryEnum;
|
|
5
5
|
(function (CategoryEnum) {
|
|
6
6
|
CategoryEnum["SUPPORT_WORKER"] = "Support Worker";
|
|
@@ -479,3 +479,19 @@ var screeningAndChildrenCheckStatus;
|
|
|
479
479
|
screeningAndChildrenCheckStatus["DECLINED"] = "declined";
|
|
480
480
|
screeningAndChildrenCheckStatus["EXPIRED"] = "expired";
|
|
481
481
|
})(screeningAndChildrenCheckStatus || (exports.screeningAndChildrenCheckStatus = screeningAndChildrenCheckStatus = {}));
|
|
482
|
+
// Push notification types for mobile app navigation
|
|
483
|
+
var PushNotificationType;
|
|
484
|
+
(function (PushNotificationType) {
|
|
485
|
+
PushNotificationType["CHAT_MESSAGE"] = "chat_message";
|
|
486
|
+
PushNotificationType["ID_VERIFICATION_REMINDER"] = "id_verification_reminder";
|
|
487
|
+
PushNotificationType["NDIS_SCREENING_REMINDER"] = "ndis_screening_reminder";
|
|
488
|
+
PushNotificationType["WWCC_REMINDER"] = "wwcc_reminder";
|
|
489
|
+
PushNotificationType["NEW_JOB_OPPORTUNITY"] = "new_job_opportunity";
|
|
490
|
+
PushNotificationType["ID_VERIFICATION_SUCCESS"] = "id_verification_success";
|
|
491
|
+
PushNotificationType["ID_VERIFICATION_RESUBMISSION_REQUESTED"] = "id_verification_resubmission_requested";
|
|
492
|
+
PushNotificationType["ID_VERIFICATION_DECLINED"] = "id_verification_declined";
|
|
493
|
+
PushNotificationType["NDIS_SCREENING_APPROVED"] = "ndis_screening_approved";
|
|
494
|
+
PushNotificationType["NDIS_SCREENING_DECLINED"] = "ndis_screening_declined";
|
|
495
|
+
PushNotificationType["WWCC_APPROVED"] = "wwcc_approved";
|
|
496
|
+
PushNotificationType["WWCC_DECLINED"] = "wwcc_declined";
|
|
497
|
+
})(PushNotificationType || (exports.PushNotificationType = PushNotificationType = {}));
|
package/dist/index.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ export { WorkHistoryInputValidation, WorkHistorySchema, } from "./schemas/workHi
|
|
|
4
4
|
export { AvailabilitiesSchemaZod, AvailabilityZodInput, } from "./schemas/availabilitySchemaValidation";
|
|
5
5
|
export { HourlyRateInputZod, HourlyRateInputZodType, } from "./schemas/hourlyRateSchemaValidation";
|
|
6
6
|
export { ServicesSchema, validateServices, } from "./schemas/businessServicesValidation";
|
|
7
|
-
export { VideoProvider, VideoValidationResult, detectVideoProvider, isValidCommunityVideoUrl, isValidYouTubeOrVimeoUrl, validateVideoLink, } from "./utils/videoValidation";
|
|
7
|
+
export { VideoProvider, VideoValidationResult, detectVideoProvider, extractYouTubeVideoId, isValidCommunityVideoUrl, isValidYouTubeOrVimeoUrl, normalizeYouTubeUrl, validateVideoLink, } from "./utils/videoValidation";
|
|
8
8
|
export { ApplicationFormValues, applicationSchema, isValidVideoUrl, } from "./schemas/applicationSchema";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isValidVideoUrl = exports.applicationSchema = exports.validateVideoLink = exports.isValidYouTubeOrVimeoUrl = exports.isValidCommunityVideoUrl = exports.detectVideoProvider = exports.validateServices = exports.ServicesSchema = exports.HourlyRateInputZod = exports.AvailabilitiesSchemaZod = exports.WorkHistorySchema = exports.EducationAndTrainingSchema = exports.UserRegistrationSchema = void 0;
|
|
3
|
+
exports.isValidVideoUrl = exports.applicationSchema = exports.validateVideoLink = exports.normalizeYouTubeUrl = exports.isValidYouTubeOrVimeoUrl = exports.isValidCommunityVideoUrl = exports.extractYouTubeVideoId = exports.detectVideoProvider = exports.validateServices = exports.ServicesSchema = exports.HourlyRateInputZod = exports.AvailabilitiesSchemaZod = exports.WorkHistorySchema = exports.EducationAndTrainingSchema = exports.UserRegistrationSchema = void 0;
|
|
4
4
|
var userValiationSchema_1 = require("./schemas/userValiationSchema");
|
|
5
5
|
Object.defineProperty(exports, "UserRegistrationSchema", { enumerable: true, get: function () { return userValiationSchema_1.UserRegistrationSchema; } });
|
|
6
6
|
var educationSchemas_1 = require("./schemas/educationSchemas");
|
|
@@ -16,8 +16,10 @@ Object.defineProperty(exports, "ServicesSchema", { enumerable: true, get: functi
|
|
|
16
16
|
Object.defineProperty(exports, "validateServices", { enumerable: true, get: function () { return businessServicesValidation_1.validateServices; } });
|
|
17
17
|
var videoValidation_1 = require("./utils/videoValidation");
|
|
18
18
|
Object.defineProperty(exports, "detectVideoProvider", { enumerable: true, get: function () { return videoValidation_1.detectVideoProvider; } });
|
|
19
|
+
Object.defineProperty(exports, "extractYouTubeVideoId", { enumerable: true, get: function () { return videoValidation_1.extractYouTubeVideoId; } });
|
|
19
20
|
Object.defineProperty(exports, "isValidCommunityVideoUrl", { enumerable: true, get: function () { return videoValidation_1.isValidCommunityVideoUrl; } });
|
|
20
21
|
Object.defineProperty(exports, "isValidYouTubeOrVimeoUrl", { enumerable: true, get: function () { return videoValidation_1.isValidYouTubeOrVimeoUrl; } });
|
|
22
|
+
Object.defineProperty(exports, "normalizeYouTubeUrl", { enumerable: true, get: function () { return videoValidation_1.normalizeYouTubeUrl; } });
|
|
21
23
|
Object.defineProperty(exports, "validateVideoLink", { enumerable: true, get: function () { return videoValidation_1.validateVideoLink; } });
|
|
22
24
|
var applicationSchema_1 = require("./schemas/applicationSchema");
|
|
23
25
|
Object.defineProperty(exports, "applicationSchema", { enumerable: true, get: function () { return applicationSchema_1.applicationSchema; } });
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -14,7 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.getAltCommunicationLabel = exports.getPreferencesLabel = exports.getGenderLabel = exports.getSupportWorkerServiceLabel = void 0;
|
|
18
17
|
// Phone validation utilities
|
|
19
18
|
__exportStar(require("./phone"), exports);
|
|
20
19
|
// Date formatting utilities
|
|
@@ -32,8 +31,4 @@ __exportStar(require("./onboarding"), exports);
|
|
|
32
31
|
// HTML sanitization utilities
|
|
33
32
|
__exportStar(require("./html"), exports);
|
|
34
33
|
// Label helper utilities
|
|
35
|
-
|
|
36
|
-
Object.defineProperty(exports, "getSupportWorkerServiceLabel", { enumerable: true, get: function () { return labels_1.getSupportWorkerServiceLabel; } });
|
|
37
|
-
Object.defineProperty(exports, "getGenderLabel", { enumerable: true, get: function () { return labels_1.getGenderLabel; } });
|
|
38
|
-
Object.defineProperty(exports, "getPreferencesLabel", { enumerable: true, get: function () { return labels_1.getPreferencesLabel; } });
|
|
39
|
-
Object.defineProperty(exports, "getAltCommunicationLabel", { enumerable: true, get: function () { return labels_1.getAltCommunicationLabel; } });
|
|
34
|
+
__exportStar(require("./labels"), exports);
|
package/dist/utils/video.d.ts
CHANGED
|
@@ -11,6 +11,15 @@ export interface VideoValidationResult {
|
|
|
11
11
|
* @returns VideoValidationResult object
|
|
12
12
|
*/
|
|
13
13
|
export declare function validateVideoLink(url: string, allowedProviders: VideoProvider[]): VideoValidationResult;
|
|
14
|
+
/**
|
|
15
|
+
* Extract YouTube video ID from various URL formats
|
|
16
|
+
* Handles: youtube.com, m.youtube.com, youtu.be, /embed, /v, etc.
|
|
17
|
+
*/
|
|
18
|
+
export declare function extractYouTubeVideoId(url: string): string | null;
|
|
19
|
+
/**
|
|
20
|
+
* Normalize YouTube URL to standard format
|
|
21
|
+
*/
|
|
22
|
+
export declare function normalizeYouTubeUrl(url: string): string | null;
|
|
14
23
|
/**
|
|
15
24
|
* Detect video provider from URL
|
|
16
25
|
*/
|
package/dist/utils/video.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.validateVideoLink = validateVideoLink;
|
|
4
|
+
exports.extractYouTubeVideoId = extractYouTubeVideoId;
|
|
5
|
+
exports.normalizeYouTubeUrl = normalizeYouTubeUrl;
|
|
4
6
|
exports.detectVideoProvider = detectVideoProvider;
|
|
5
7
|
exports.isValidYouTubeOrVimeoUrl = isValidYouTubeOrVimeoUrl;
|
|
6
8
|
exports.isValidCommunityVideoUrl = isValidCommunityVideoUrl;
|
|
@@ -34,23 +36,60 @@ function validateVideoLink(url, allowedProviders) {
|
|
|
34
36
|
}
|
|
35
37
|
return { isValid: true, provider };
|
|
36
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Extract YouTube video ID from various URL formats
|
|
41
|
+
* Handles: youtube.com, m.youtube.com, youtu.be, /embed, /v, etc.
|
|
42
|
+
*/
|
|
43
|
+
function extractYouTubeVideoId(url) {
|
|
44
|
+
if (!url)
|
|
45
|
+
return null;
|
|
46
|
+
const trimmed = url.trim();
|
|
47
|
+
let videoId = null;
|
|
48
|
+
// Handle youtu.be/VIDEO_ID
|
|
49
|
+
if (trimmed.includes('youtu.be/')) {
|
|
50
|
+
const match = trimmed.match(/youtu\.be\/([a-zA-Z0-9_-]{11})/);
|
|
51
|
+
videoId = match ? match[1] : null;
|
|
52
|
+
}
|
|
53
|
+
// Handle youtube.com/watch?v=VIDEO_ID (works for www, m, etc.)
|
|
54
|
+
else if (trimmed.includes('youtube.com/watch')) {
|
|
55
|
+
const match = trimmed.match(/[?&]v=([a-zA-Z0-9_-]{11})/);
|
|
56
|
+
videoId = match ? match[1] : null;
|
|
57
|
+
}
|
|
58
|
+
// Handle youtube.com/embed/VIDEO_ID
|
|
59
|
+
else if (trimmed.includes('youtube.com/embed/')) {
|
|
60
|
+
const match = trimmed.match(/\/embed\/([a-zA-Z0-9_-]{11})/);
|
|
61
|
+
videoId = match ? match[1] : null;
|
|
62
|
+
}
|
|
63
|
+
// Handle youtube.com/v/VIDEO_ID
|
|
64
|
+
else if (trimmed.includes('youtube.com/v/')) {
|
|
65
|
+
const match = trimmed.match(/\/v\/([a-zA-Z0-9_-]{11})/);
|
|
66
|
+
videoId = match ? match[1] : null;
|
|
67
|
+
}
|
|
68
|
+
return videoId;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Normalize YouTube URL to standard format
|
|
72
|
+
*/
|
|
73
|
+
function normalizeYouTubeUrl(url) {
|
|
74
|
+
const videoId = extractYouTubeVideoId(url);
|
|
75
|
+
return videoId ? `https://www.youtube.com/watch?v=${videoId}` : null;
|
|
76
|
+
}
|
|
37
77
|
/**
|
|
38
78
|
* Detect video provider from URL
|
|
39
79
|
*/
|
|
40
80
|
function detectVideoProvider(url) {
|
|
41
|
-
|
|
42
|
-
|
|
81
|
+
if (!url)
|
|
82
|
+
return null;
|
|
83
|
+
const lower = url.toLowerCase();
|
|
84
|
+
if ((lower.includes("youtube.com") || lower.includes("youtu.be")) && extractYouTubeVideoId(url)) {
|
|
43
85
|
return "youtube";
|
|
44
86
|
}
|
|
45
|
-
if (
|
|
87
|
+
if (lower.includes("vimeo.com"))
|
|
46
88
|
return "vimeo";
|
|
47
|
-
|
|
48
|
-
if (trimmedUrl.includes("loom.com")) {
|
|
89
|
+
if (lower.includes("loom.com"))
|
|
49
90
|
return "loom";
|
|
50
|
-
|
|
51
|
-
if (trimmedUrl.includes("tiktok.com")) {
|
|
91
|
+
if (lower.includes("tiktok.com"))
|
|
52
92
|
return "tiktok";
|
|
53
|
-
}
|
|
54
93
|
return null;
|
|
55
94
|
}
|
|
56
95
|
/**
|
|
@@ -6,26 +6,26 @@ export interface VideoValidationResult {
|
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* Unified video link validation function
|
|
9
|
-
* @param url - The video URL to validate
|
|
10
|
-
* @param allowedProviders - Array of allowed video providers
|
|
11
|
-
* @returns VideoValidationResult object
|
|
12
9
|
*/
|
|
13
10
|
export declare function validateVideoLink(url: string, allowedProviders: VideoProvider[]): VideoValidationResult;
|
|
11
|
+
/**
|
|
12
|
+
* Extract YouTube video ID from various URL formats
|
|
13
|
+
* Handles: youtube.com, m.youtube.com, youtu.be, /embed, /v, etc.
|
|
14
|
+
*/
|
|
15
|
+
export declare function extractYouTubeVideoId(url: string): string | null;
|
|
16
|
+
/**
|
|
17
|
+
* Normalize YouTube URL to standard format
|
|
18
|
+
*/
|
|
19
|
+
export declare function normalizeYouTubeUrl(url: string): string | null;
|
|
14
20
|
/**
|
|
15
21
|
* Detect video provider from URL
|
|
16
|
-
* @param url - The video URL
|
|
17
|
-
* @returns VideoProvider or null if not detected
|
|
18
22
|
*/
|
|
19
23
|
export declare function detectVideoProvider(url: string): VideoProvider | null;
|
|
20
24
|
/**
|
|
21
25
|
* Convenience function for YouTube and Vimeo only (commonly used)
|
|
22
|
-
* @param url - The video URL to validate
|
|
23
|
-
* @returns boolean
|
|
24
26
|
*/
|
|
25
27
|
export declare function isValidYouTubeOrVimeoUrl(url: string): boolean;
|
|
26
28
|
/**
|
|
27
29
|
* Convenience function for community posts (all providers)
|
|
28
|
-
* @param url - The video URL to validate
|
|
29
|
-
* @returns boolean
|
|
30
30
|
*/
|
|
31
31
|
export declare function isValidCommunityVideoUrl(url: string): boolean;
|
|
@@ -1,25 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.validateVideoLink = validateVideoLink;
|
|
4
|
+
exports.extractYouTubeVideoId = extractYouTubeVideoId;
|
|
5
|
+
exports.normalizeYouTubeUrl = normalizeYouTubeUrl;
|
|
4
6
|
exports.detectVideoProvider = detectVideoProvider;
|
|
5
7
|
exports.isValidYouTubeOrVimeoUrl = isValidYouTubeOrVimeoUrl;
|
|
6
8
|
exports.isValidCommunityVideoUrl = isValidCommunityVideoUrl;
|
|
7
9
|
/**
|
|
8
10
|
* Unified video link validation function
|
|
9
|
-
* @param url - The video URL to validate
|
|
10
|
-
* @param allowedProviders - Array of allowed video providers
|
|
11
|
-
* @returns VideoValidationResult object
|
|
12
11
|
*/
|
|
13
12
|
function validateVideoLink(url, allowedProviders) {
|
|
14
13
|
if (!url || url.trim() === "") {
|
|
15
14
|
return { isValid: true }; // Empty URL is valid (optional field)
|
|
16
15
|
}
|
|
17
|
-
const
|
|
18
|
-
// Validate URL format
|
|
19
|
-
if (!isValidURL(trimmedUrl)) {
|
|
20
|
-
return { isValid: false, error: "Invalid URL format" };
|
|
21
|
-
}
|
|
22
|
-
const provider = detectVideoProvider(trimmedUrl);
|
|
16
|
+
const provider = detectVideoProvider(url);
|
|
23
17
|
if (!provider) {
|
|
24
18
|
return {
|
|
25
19
|
isValid: false,
|
|
@@ -35,69 +29,63 @@ function validateVideoLink(url, allowedProviders) {
|
|
|
35
29
|
return { isValid: true, provider };
|
|
36
30
|
}
|
|
37
31
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* @returns VideoProvider or null if not detected
|
|
32
|
+
* Extract YouTube video ID from various URL formats
|
|
33
|
+
* Handles: youtube.com, m.youtube.com, youtu.be, /embed, /v, etc.
|
|
41
34
|
*/
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
35
|
+
function extractYouTubeVideoId(url) {
|
|
36
|
+
if (!url)
|
|
37
|
+
return null;
|
|
38
|
+
const trimmed = url.trim();
|
|
39
|
+
let videoId = null;
|
|
40
|
+
// Handle youtu.be/VIDEO_ID
|
|
41
|
+
if (trimmed.includes('youtu.be/')) {
|
|
42
|
+
const match = trimmed.match(/youtu\.be\/([a-zA-Z0-9_-]{11})/);
|
|
43
|
+
videoId = match ? match[1] : null;
|
|
51
44
|
}
|
|
52
|
-
//
|
|
53
|
-
if (
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
return "vimeo";
|
|
57
|
-
}
|
|
45
|
+
// Handle youtube.com/watch?v=VIDEO_ID (works for www, m, etc.)
|
|
46
|
+
else if (trimmed.includes('youtube.com/watch')) {
|
|
47
|
+
const match = trimmed.match(/[?&]v=([a-zA-Z0-9_-]{11})/);
|
|
48
|
+
videoId = match ? match[1] : null;
|
|
58
49
|
}
|
|
59
|
-
//
|
|
60
|
-
if (
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
return "loom";
|
|
64
|
-
}
|
|
50
|
+
// Handle youtube.com/embed/VIDEO_ID
|
|
51
|
+
else if (trimmed.includes('youtube.com/embed/')) {
|
|
52
|
+
const match = trimmed.match(/\/embed\/([a-zA-Z0-9_-]{11})/);
|
|
53
|
+
videoId = match ? match[1] : null;
|
|
65
54
|
}
|
|
66
|
-
//
|
|
67
|
-
if (
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
if (tiktokRegex1.test(url) || tiktokRegex2.test(url)) {
|
|
71
|
-
return "tiktok";
|
|
72
|
-
}
|
|
55
|
+
// Handle youtube.com/v/VIDEO_ID
|
|
56
|
+
else if (trimmed.includes('youtube.com/v/')) {
|
|
57
|
+
const match = trimmed.match(/\/v\/([a-zA-Z0-9_-]{11})/);
|
|
58
|
+
videoId = match ? match[1] : null;
|
|
73
59
|
}
|
|
74
|
-
return
|
|
60
|
+
return videoId;
|
|
75
61
|
}
|
|
76
62
|
/**
|
|
77
|
-
*
|
|
78
|
-
* @param url - The URL to validate
|
|
79
|
-
* @returns boolean
|
|
63
|
+
* Normalize YouTube URL to standard format
|
|
80
64
|
*/
|
|
81
|
-
function
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
65
|
+
function normalizeYouTubeUrl(url) {
|
|
66
|
+
const videoId = extractYouTubeVideoId(url);
|
|
67
|
+
return videoId ? `https://www.youtube.com/watch?v=${videoId}` : null;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Detect video provider from URL
|
|
71
|
+
*/
|
|
72
|
+
function detectVideoProvider(url) {
|
|
73
|
+
if (!url)
|
|
74
|
+
return null;
|
|
75
|
+
const lower = url.toLowerCase();
|
|
76
|
+
if ((lower.includes("youtube.com") || lower.includes("youtu.be")) && extractYouTubeVideoId(url)) {
|
|
77
|
+
return "youtube";
|
|
95
78
|
}
|
|
79
|
+
if (lower.includes("vimeo.com"))
|
|
80
|
+
return "vimeo";
|
|
81
|
+
if (lower.includes("loom.com"))
|
|
82
|
+
return "loom";
|
|
83
|
+
if (lower.includes("tiktok.com"))
|
|
84
|
+
return "tiktok";
|
|
85
|
+
return null;
|
|
96
86
|
}
|
|
97
87
|
/**
|
|
98
88
|
* Convenience function for YouTube and Vimeo only (commonly used)
|
|
99
|
-
* @param url - The video URL to validate
|
|
100
|
-
* @returns boolean
|
|
101
89
|
*/
|
|
102
90
|
function isValidYouTubeOrVimeoUrl(url) {
|
|
103
91
|
const result = validateVideoLink(url, ["youtube", "vimeo"]);
|
|
@@ -105,15 +93,8 @@ function isValidYouTubeOrVimeoUrl(url) {
|
|
|
105
93
|
}
|
|
106
94
|
/**
|
|
107
95
|
* Convenience function for community posts (all providers)
|
|
108
|
-
* @param url - The video URL to validate
|
|
109
|
-
* @returns boolean
|
|
110
96
|
*/
|
|
111
97
|
function isValidCommunityVideoUrl(url) {
|
|
112
|
-
const result = validateVideoLink(url, [
|
|
113
|
-
"youtube",
|
|
114
|
-
"vimeo",
|
|
115
|
-
"loom",
|
|
116
|
-
"tiktok",
|
|
117
|
-
]);
|
|
98
|
+
const result = validateVideoLink(url, ["youtube", "vimeo", "loom", "tiktok"]);
|
|
118
99
|
return result.isValid;
|
|
119
100
|
}
|