Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

attachment-detection

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

attachment-detection - npm Package Compare versions

Comparing version 0.2.0-0 to 0.2.1-0

lib/detectors/helper.js

31

lib/detector.js

@@ -0,1 +1,5 @@

var _ = require('underscore'),
Helper = require('./detectors/helper'),
request = require('request');
var _detect = function(link, handlers, callback) {

@@ -29,4 +33,7 @@ var handler, index = 0, result = {

module.exports = (function() {
var Detector = function(handlers) {
this.handlers = handlers || [];
var Detector = function(options) {
this.handlers = [];
this.options = _.defaults(options || {}, {
follow: true
});
};

@@ -40,3 +47,5 @@

detect: function(links, callback) {
var attachments = [], self = this, count;
var attachments = [],
self = this,
count;

@@ -58,5 +67,15 @@ if (Object.prototype.toString.call(links) != "[object Array]") {

var detectClosure = (function (index) {
_detect(links[index], self.handlers, function (result) {
attachments[index] = result;
done();
var resolveLink = function(url, callback) {
if (!self.options.follow) return callback(url);
request(url, function (err, response, body) {
callback(response.request.uri.href);
});
};
resolveLink(Helper.fullUrl(links[index]), function (link) {
_detect(link, self.handlers, function (result) {
attachments[index] = result;
done();
});
});

@@ -63,0 +82,0 @@ });

7

lib/index.js

@@ -8,6 +8,7 @@ var detector = require('./detector');

wrapper.Detector = detector;
wrapper.YouTube = require('./youtube');
wrapper.Image = require('./image');
wrapper.Link = require('./link');
wrapper.YouTube = require('./detectors/youtube');
wrapper.SoundCloud = require('./detectors/soundcloud');
wrapper.Image = require('./detectors/image');
wrapper.Link = require('./detectors/link');
module.exports = wrapper;
{
"name": "attachment-detection",
"version": "0.2.0-0",
"version": "0.2.1-0",
"dependencies": {
"request": "2.10.0",
"cheerio": "0.9.2"
"cheerio": "0.9.2",
"underscore": "*"
},

@@ -8,0 +9,0 @@ "devDependencies": {

@@ -39,3 +39,2 @@ var buster = require('buster'),

detector.detect(['http://www.paintballarena.dk/'], function(result) {
console.log(result[0].description);
expect(!!~result[0].description.indexOf('Europas største indendørs Paintball- og eventcenter, høvdingebold, skydebane, Laserskydning, Sumo brydning, human football, gladiator kamp og rodeo tyr, Bungee tag, Multisport index')).toBeTrue();

@@ -42,0 +41,0 @@ done();

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc