fix(sdk): prefer iframe for embed-page urls in goView import
This commit is contained in:
parent
ca3f5670e8
commit
f87d82fe15
@ -483,6 +483,19 @@ export function convertGoViewProjectToScreen(input: GoViewProjectLike | GoViewSt
|
|||||||
const optionSaysVideo = looksLikeVideoOption(option);
|
const optionSaysVideo = looksLikeVideoOption(option);
|
||||||
const optionSaysIframe = looksLikeIframeOption(option);
|
const optionSaysIframe = looksLikeIframeOption(option);
|
||||||
|
|
||||||
|
// Some goView/fork widgets mislabel embedded platforms (YouTube/Vimeo/etc) as "Video"
|
||||||
|
// even though they are best represented as an iframe (a web page, not a media stream).
|
||||||
|
const urlLike = pickUrlLike(option);
|
||||||
|
const urlLooksLikeEmbedPage =
|
||||||
|
!!urlLike &&
|
||||||
|
/(youtube\.com|youtu\.be|vimeo\.com|bilibili\.com|youku\.com|iqiyi\.com|tencent|douyin\.com|kuaishou\.com)/i.test(
|
||||||
|
urlLike,
|
||||||
|
) &&
|
||||||
|
// Keep actual media URLs as video.
|
||||||
|
!/\.(mp4|m3u8|flv|webm|mov|m4v|ogv)(\?|#|$)/i.test(urlLike) &&
|
||||||
|
!/^data:video\//i.test(urlLike) &&
|
||||||
|
!/^(rtsp|rtmp):\/\//i.test(urlLike);
|
||||||
|
|
||||||
// Prefer evidence from the option payload over the widget key.
|
// Prefer evidence from the option payload over the widget key.
|
||||||
// Many forks mislabel widget keys (e.g. "Text*" / "Image*"), but the option payload
|
// Many forks mislabel widget keys (e.g. "Text*" / "Image*"), but the option payload
|
||||||
// clearly indicates iframe/video/image.
|
// clearly indicates iframe/video/image.
|
||||||
@ -490,7 +503,9 @@ export function convertGoViewProjectToScreen(input: GoViewProjectLike | GoViewSt
|
|||||||
optionSaysIframe
|
optionSaysIframe
|
||||||
? 'iframe'
|
? 'iframe'
|
||||||
: optionSaysVideo
|
: optionSaysVideo
|
||||||
? 'video'
|
? urlLooksLikeEmbedPage
|
||||||
|
? 'iframe'
|
||||||
|
: 'video'
|
||||||
: optionSaysImage
|
: optionSaysImage
|
||||||
? 'image'
|
? 'image'
|
||||||
: isIframe(c)
|
: isIframe(c)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user