diff --git a/NUXT/plugins/utils.js b/NUXT/plugins/utils.js index 69b0e4f..026c138 100644 --- a/NUXT/plugins/utils.js +++ b/NUXT/plugins/utils.js @@ -42,10 +42,18 @@ function getMutationByKey(key, mutations) { return mutations.find((mutation) => mutation.entityKey === key).payload; } +function linkParser(url) { + var regExp = + /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#&?]*).*/; + var match = url.match(regExp); + return match && match[7].length == 11 ? match[7] : false; +} + module.exports = { getBetweenStrings, hexToRgb, rgbToHex, getCpn, getMutationByKey, + linkParser, };