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

impurge

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

impurge - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

33

impurge.js
var cheerio = require("cheerio")
, request = require("request")
impurge = []
var impurge = [];

@@ -8,11 +8,12 @@ module.exports = impurge;

//pattern used for extraction of the links from the html
imgur_url_pattern = RegExp("^http://((www)|(i)\.)?imgur.com/[./a-zA-Z0-9&,]+","ig")
var imgur_url_pattern = RegExp("^http://((www)|(i)\.)?imgur.com/[./a-zA-Z0-9&,]+","ig");
//patterns used to check URL patterns
imgur_album_url_pattern = RegExp("^http://(?:www\.)?imgur\.com/a/([a-zA-Z0-9]+)","i")
imgur_hashes_pattern = RegExp("imgur\.com/(([a-zA-Z0-9]{5,7}[&,]?)+)","i")
imgur_image_pattern = RegExp("^http://(www\.)?(i\.)?imgur\.com/.{3,7}\.((jpg)|(gif))","ig")
var imgur_album_url_pattern = RegExp("^http://(?:www\.)?imgur\.com/a/([a-zA-Z0-9]+)","i");
var imgur_gallery_url_pattern = RegExp("^http://(?:www\.)?imgur\.com/gallery/([a-zA-Z0-9]+)","i");
var imgur_hashes_pattern = RegExp("imgur\.com/(([a-zA-Z0-9]{5,7}[&,]?)+)","i");
var imgur_image_pattern = RegExp("^http://(www\.)?(i\.)?imgur\.com/.{3,7}\.((jpg)|(gif))","ig");
//determines the link provided to module
determine_link_type = function (url, callback) {
var determine_link_type = function (url, callback) {
if ( imgur_image_pattern.exec(url) ) {

@@ -22,10 +23,17 @@ callback(null,'image_url',null,url);

else if ( imgur_album_url_pattern.exec(url) ) {
var match = imgur_album_url_pattern.exec(url)
var match = imgur_album_url_pattern.exec(url);
if (match){
var hashes = match[1].split(/[,&]/)
}
callback(null,'album_url',hashes);
}
else if ( imgur_gallery_url_pattern.exec(url) ) {
var match = imgur_gallery_url_pattern.exec(url);
if (match){
var hashes = match[1].split(/[,&]/);
}
callback(null,'album_url',hashes);
}
callback(null,'gallery_url',hashes);
}
else if ( imgur_hashes_pattern.exec(url) ) {
var match = imgur_hashes_pattern.exec(url)
var match = imgur_hashes_pattern.exec(url);
if (match){

@@ -59,2 +67,5 @@ var hashes = match[1].split(/[,&]/);

}
else if (type === 'gallery_url'){
var url = 'http://api.imgur.com/2/album/'+id+".json"
}
else {

@@ -67,3 +78,3 @@ callback("unknown_link_error")

} catch (err) {
callback("impurge: JSON parsing error");
callback("impurge: JSON parsing error w/following URL: "+ url);
}

@@ -70,0 +81,0 @@

@@ -9,3 +9,3 @@ {

},
"version": "0.0.4",
"version": "0.0.5",
"description": "takes any imgur url and returns an array of direct image files",

@@ -17,3 +17,4 @@ "engines": {

"mocha": "*",
"request": "~2.11.4"
"request": "~2.11.4",
"cheerio": "*"
},

@@ -24,8 +25,5 @@ "devDependencies": {

"keywords": [
"digitalocean",
"digital",
"ocean",
"api",
"cloud",
"ssd"
"imgur",
"parser",
"image"
],

@@ -32,0 +30,0 @@ "author": "hortinstein",

@@ -26,6 +26,6 @@ var should = require('should');

it('should find 2 pictures', function(done){
impurge.purge("http://imgur.com/a/mj1YZ", function (e,r) {
r.length.should.equal(3);
r[0].should.equal('http://i.imgur.com/elfZxNm.jpg');
r[1].should.equal('http://i.imgur.com/WKNJN3K.jpg');
impurge.purge("http://imgur.com/a/9uIQf", function (e,r) {
r.length.should.equal(2);
r[0].should.equal('http://i.imgur.com/Z6ft3xZ.jpg');
r[1].should.equal('http://i.imgur.com/xSW842C.jpg');
done();

@@ -44,4 +44,13 @@ })

});
describe('gallery hash url', function () {
it('should find 4 pictures', function(done){
impurge.purge("http://imgur.com/gallery/Ptn4M", function (e,r) {
r.length.should.equal(4);
r[0].should.equal('http://i.imgur.com/tYx0Ebf.gif');
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