@social-embed/lib
Version:
URL detection and parsing for embed providers (YouTube, other OEmbed compatible providers),
53 lines • 1.83 kB
TypeScript
import { EmbedProvider } from '../provider';
/**
* A regular expression for matching DailyMotion video links.
*
* @remarks
* This pattern handles optional protocols (`http`/`https`), optional `www.`, and
* either `dailymotion.com/video/` (which may also have `/embed` in it) or `dai.ly/`.
* It also supports an optional `?playlist=<id>` segment.
*
* **Credit**: [Stack Overflow](https://stackoverflow.com/a/50644701) (2021-03-14: Support `?playlist`)
*
* @example
* ```
* // Matches e.g. "https://www.dailymotion.com/video/x7znrd0"
* // Also matches "dailymotion.com/embed/video/x7znrd0"
* ```
*/
export declare const dailyMotionUrlRegex: RegExp;
/**
* Extracts a DailyMotion video ID from a given URL string.
*
* @param url - The URL that may match DailyMotion patterns.
* @returns The extracted DailyMotion video ID, or an empty string if none found.
*
* @example
* ```ts
* const dmId = getDailyMotionIdFromUrl("https://www.dailymotion.com/video/x7znrd0");
* console.log(dmId); // "x7znrd0"
* ```
*/
export declare const getDailyMotionIdFromUrl: (url: string) => string;
/**
* Constructs an embeddable DailyMotion URL from the given ID.
*
* @param id - The DailyMotion video ID.
* @returns A URL suitable for embedding in an `<iframe>`.
*
* @example
* ```ts
* console.log(getDailyMotionEmbedFromId("x7znrd0"));
* // "https://www.dailymotion.com/embed/video/x7znrd0"
* ```
*/
export declare const getDailyMotionEmbedFromId: (id: string) => string;
/**
* A provider implementation for detecting and building embed URLs for DailyMotion videos.
*
* @remarks
* This object satisfies the {@link EmbedProvider} interface, allowing usage in a registry or
* with `convertUrlToEmbedUrl()`.
*/
export declare const DailyMotionProvider: EmbedProvider;
//# sourceMappingURL=dailymotion.d.ts.map