0c29506402
- Extract utility functions from component files into dedicated modules to fix react-refresh/only-export-components warnings: - parseBadgeDefinition -> src/lib/parseBadgeDefinition.ts - parseProfileBadges -> src/lib/parseProfileBadges.ts - getColors, paletteToTheme -> src/lib/colorMomentUtils.ts - parseDimToAspectRatio, eventToMediaItem -> src/lib/mediaUtils.ts - isAudioUrl, isImageUrl, isVideoUrl -> src/lib/mediaTypeDetection.ts - buildKindOptions, parseSelectedKinds -> src/lib/feedFilterUtils.ts - useVideoThumbnail -> src/hooks/useVideoThumbnail.ts - useEnvelopeDimensions -> src/hooks/useEnvelopeDimensions.ts - usePortalContainer -> src/hooks/usePortalContainer.ts - useAudioPlayer -> src/contexts/audioPlayerContextDef.ts - SubHeaderBar context/hooks -> src/components/SubHeaderBarContext.ts - EmotionDev hooks -> src/blobbi/dev/useEmotionDev.ts - BlobbiActions context def -> BlobbiActionsContextDef.ts - Remove export from internal-only functions (useEventComments, parseEmojiPack, useScrollCarets, formatEffectSummary, getSortedEffectEntries) - Fix react-hooks/exhaustive-deps warnings by adding missing dependencies to useEffect/useCallback/useMemo hooks across 14 files - Fix logical expression dependency warnings by wrapping conditional values (tasks, pubkeys, authorPubkeys) in useMemo - Move module-level constants (CORE_TAB_IDS, CORE_TAB_LABELS, DEFAULT_TAB_LABELS) out of ProfilePage component body - Reorder usePushNotifications hooks so syncPreferences is defined before enable to fix block-scoped variable error
27 lines
1.1 KiB
TypeScript
27 lines
1.1 KiB
TypeScript
/** Audio file extensions used to detect audio URLs. */
|
|
const AUDIO_EXTENSIONS = /\.(mp3|mpga|ogg|oga|wav|flac|aac|m4a|opus|weba|webm|spx|caf)(\?.*)?$/i;
|
|
|
|
/** Image file extensions used to detect image URLs. */
|
|
const IMAGE_EXTENSIONS = /\.(jpe?g|png|gif|webp|svg|avif)(\?.*)?$/i;
|
|
|
|
/** Video file extensions used to detect video URLs. */
|
|
const VIDEO_EXTENSIONS = /\.(mp4|webm|mov|qt)(\?.*)?$/i;
|
|
|
|
/** Check whether a URL points to an audio file by extension. */
|
|
export function isAudioUrl(url: string): boolean {
|
|
if (!url.startsWith('http://') && !url.startsWith('https://')) return false;
|
|
return AUDIO_EXTENSIONS.test(url);
|
|
}
|
|
|
|
/** Check whether a URL points to an image file by extension. */
|
|
export function isImageUrl(url: string): boolean {
|
|
if (!url.startsWith('http://') && !url.startsWith('https://')) return false;
|
|
return IMAGE_EXTENSIONS.test(url);
|
|
}
|
|
|
|
/** Check whether a URL points to a video file by extension. */
|
|
export function isVideoUrl(url: string): boolean {
|
|
if (!url.startsWith('http://') && !url.startsWith('https://')) return false;
|
|
return VIDEO_EXTENSIONS.test(url);
|
|
}
|