Skip to content

Instantly share code, notes, and snippets.

Last active July 22, 2021 09:20
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
This code snippet conversts a given Wistia shareable URL to an Id
/// Converts fully qualified Wistia Url to video id.
/// If videoId is passed as url then we will skip conversion.
/// This will match:
String? convertUrlToId(String url, {bool trimWhitespaces = true}) {
bool isWistiaVideoId =
!url.contains(RegExp(r'https?:\/\/')) && url.length == 10;
if (isWistiaVideoId) return url;
if (trimWhitespaces) url = url.trim();
var wistiaShareLinkPattern =
RegExpMatch? match = wistiaShareLinkPattern.firstMatch(url);
return match?.group(1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment