@social-embed/lib
Version:
URL detection and parsing for embed providers (YouTube, other OEmbed compatible providers),
49 lines • 1.77 kB
TypeScript
import { EmbedProvider } from '../provider';
/**
* A regex pattern that matches Vimeo video URLs.
*
* @remarks
* Credit: [Stack Overflow](https://stackoverflow.com/a/50777192) (2021-03-14: modified / fixed to ignore unused groups).
* This pattern handles optional protocols (`https?://`), optional subdomains (`www.`, `player.`), and various Vimeo URL structures:
* - `vimeo.com/channels/…`
* - `vimeo.com/groups/…/videos/…`
* - `vimeo.com/video/…`
* - `vimeo.com/…`
*/
export declare const vimeoUrlRegex: RegExp;
/**
* Extracts the numeric Vimeo video ID from a given URL.
*
* @param url - The Vimeo URL string.
* @returns The extracted numeric ID, or an empty string if no match is found.
*
* @example
* ```ts
* const vimeoId = getVimeoIdFromUrl("https://vimeo.com/channels/staffpicks/134668506");
* console.log(vimeoId); // "134668506"
* ```
*/
export declare const getVimeoIdFromUrl: (url: string) => string;
/**
* Constructs an embeddable Vimeo URL from the given numeric video ID.
*
* @param id - The numeric Vimeo ID.
* @returns A URL suitable for embedding in an `<iframe>`.
*
* @example
* ```ts
* const embedUrl = getVimeoEmbedUrlFromId("134668506");
* console.log(embedUrl); // "https://player.vimeo.com/video/134668506"
* ```
*/
export declare const getVimeoEmbedUrlFromId: (id: string) => string;
/**
* A provider implementation for Vimeo, conforming to the {@link EmbedProvider} interface.
*
* @remarks
* - `canParseUrl()` uses {@link vimeoUrlRegex} to detect Vimeo URLs.
* - `getIdFromUrl()` extracts the numeric ID from recognized Vimeo links.
* - `getEmbedUrlFromId()` builds an embeddable `<iframe>` URL for Vimeo.
*/
export declare const VimeoProvider: EmbedProvider;
//# sourceMappingURL=vimeo.d.ts.map