Socket
Socket
Sign inDemoInstall

youtube-video

Package Overview
Dependencies
1
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.0 to 2.2.0

34

index.js
var extend = require('extend');
var findall = require("findall");
var newElement = require('new-element');

@@ -26,3 +25,5 @@ var sdk = require('require-sdk')('https://www.youtube.com/iframe_api', 'YT');

sdk(function (error, youtube) {
var playerVars = {};
var videoId = pickID(input),
playerVars = {},
playlist;

@@ -37,2 +38,12 @@ api = youtube;

// If we don't have a video ID, check to see if `input` is a playlist.
if (!videoId) {
playlist = /(?:\?|&)list=([^&]+)/.exec(input);
if (playlist) {
playerVars.listType = playerVars.listType || 'playlist';
playerVars.list = playlist[1];
}
}
// Automatically cast any boolean values as integers.

@@ -51,3 +62,3 @@ for (var i in playerVars) {

playerVars: playerVars,
videoId: pickID(input),
videoId: videoId,
events: {

@@ -80,8 +91,19 @@ 'onReady': onPlayerReady,

/**
* Parse the video ID out of a string.
*
* @param {string} input - The input string, which could be a URL or a video ID.
* @returns {string|null} Either the parsed video ID or NULL.
*/
function pickID (input) {
if (!/\./.test(input)) return input;
var videoId;
var match = findall(input, /(?:\?|&)v=([^&]+)/);
// Return early if there's no ".", as it's clearly not a URL.
if (!/\./.test(input)) {
return input;
}
if (match) return match[0];
videoId = /(?:\?|&)v=([^&]+)/.exec(input);
return videoId ? videoId[1] : null;
}

@@ -88,0 +110,0 @@

7

package.json
{
"name": "youtube-video",
"version": "2.1.0",
"version": "2.2.0",
"description": "Minimalistic API to play Youtube videos",

@@ -11,5 +11,4 @@ "main": "index.js",

"extend": "^3.0.0",
"findall": "0.0.4",
"new-element": "0.0.1",
"require-sdk": "0.0.0"
"new-element": "azer/new-element",
"require-sdk": "azer/require-sdk"
},

@@ -16,0 +15,0 @@ "devDependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc