jodit
Version:
Jodit is an awesome and useful wysiwyg editor with filebrowser
29 lines (28 loc) • 1.28 kB
JavaScript
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net
*/
/**
* @module plugins/clean-html
*/
// The embed URLs produced by the built-in Video button (see
// `convertMediaUrlToVideoEmbed`): `//www.youtube.com/embed/<id>` and
// `//player.vimeo.com/video/<id>`. `youtube-nocookie.com` is the privacy
// variant YouTube offers for the same `/embed/` player. The `/embed/` and
// `/video/` path prefixes are required so a bare provider link
// (`youtube.com/@somebody`) is not treated as a player.
const YOUTUBE_EMBED = /^(https?:)?\/\/(www\.|m\.|music\.)?youtube(-nocookie)?\.com\/embed\//i;
const VIMEO_EMBED = /^(https?:)?\/\/player\.vimeo\.com\/video\//i;
/**
* Whether an `<iframe>` `src` points at a recognized YouTube/Vimeo video
* player. Such iframes are inserted intentionally through the Video button, so
* clean-html must not strip them (`denyTags` includes `iframe` by default) or
* neutralize them with an empty `sandbox=""` (#1381). Arbitrary/bare iframes
* are still removed.
*
* @private
*/
export function isAllowedMediaEmbed(src) {
return YOUTUBE_EMBED.test(src) || VIMEO_EMBED.test(src);
}