@social-embed/lib
Version:
URL detection and parsing for embed providers (YouTube, other OEmbed compatible providers),
31 lines • 1.23 kB
TypeScript
import { EmbedProvider } from './provider';
export declare const isString: (val: unknown) => val is string;
export declare const isRegExp: (val: unknown) => val is RegExp;
/**
* Factory to create regex matchers
*
* @param regex Regular expression or string pattern to match
*/
export declare const matcher: (regex: RegExp | string) => ((value: string) => boolean);
/**
* Returns the first registered provider that can handle a given URL.
*
* @remarks
* Internally calls {@link EmbedProviderRegistry.findProviderByUrl}.
* Returns `undefined` if no known provider matches.
*
* @param url - The URL to check.
*/
export declare function getProviderFromUrl(url: string): EmbedProvider | undefined;
/**
* Converts a recognized media URL to an embeddable iframe-friendly URL.
*
* @remarks
* - If the URL is recognized, calls the provider’s `getIdFromUrl()` and `getEmbedUrlFromId()`.
* - If no provider is found, returns an empty string.
*
* @param url - The user-supplied media URL (e.g., a YouTube link).
* @returns The embeddable URL string (e.g., `https://www.youtube.com/embed/...`) or an empty string.
*/
export declare function convertUrlToEmbedUrl(url: string): string;
//# sourceMappingURL=utils.d.ts.map