diff options
author | przemyslawpluta <przemekpluta@hotmail.com> | 2014-08-01 11:08:47 +0100 |
---|---|---|
committer | przemyslawpluta <przemekpluta@hotmail.com> | 2014-08-01 11:08:47 +0100 |
commit | 0df2ae550c4f5e16298d1cbdde788ce7acc575e3 (patch) | |
tree | 0f0e2ca2c663ba93de6f3e6fe3fb8f417f9a2082 /lib | |
parent | 7b3635eecc39f8aca57d9b7a00fc638d99dddbd7 (diff) | |
download | mongo-edu-0df2ae550c4f5e16298d1cbdde788ce7acc575e3.zip |
update
parse html href links
cleanup
Diffstat (limited to 'lib')
-rw-r--r-- | lib/login.js | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/lib/login.js b/lib/login.js index 2dd9bef..968b518 100644 --- a/lib/login.js +++ b/lib/login.js @@ -162,7 +162,7 @@ module.exports = { 'use strict'; - var videos = [], state = false, list, $, current; + var videos = [], list, $, current; if (argv.cw || argv.cwd) { return coursewareHandler.filterVideos(opt, host, jar, argv, callback); } @@ -178,24 +178,17 @@ module.exports = { current = list.find('code').text(); - if ((current.indexOf('http://') !== -1) || (current.indexOf('https://') !== -1)) { - videos = _.compact(current.split('\n')); - } + if (current.match(/http:\/\/|https:\/\//)) { videos = _.compact(current.split('\n')); } if (!videos.length) { list.children('p').children().each(function each(i, item) { - var current = $(item); - if (current.attr('href')) { - videos.push({ name: current.text().split('-')[0], value: current.attr('href') }); - } + var current = $(item), href = current.attr('href'); + if (href && href.match(/http:\/\/|https:\/\//)) { videos.push(href); } }); - - if (videos.length) { videos.unshift({name: 'All', value: 'all', checked: true}, {name: 'Cancel', value: 'cancel'}); } - state = true; } - return callback(null, videos, state); + return callback(null, videos); } callback(new Error(res.statusCode)); |