Permalink
Browse files

FIX: Pass jshint.

  • Loading branch information...
1 parent 59e5e3e commit b2c4e9adbd238a6129369691661d450d7dd5df20 @lbdremy committed Feb 2, 2013
Showing with 33 additions and 31 deletions.
  1. +1 −1 lib/browser.js
  2. +12 −17 lib/defaults/index.js
  3. +7 −1 lib/error/scrapinode-error.js
  4. +1 −1 lib/route.js
  5. +2 −2 lib/router.js
  6. +4 −4 lib/scrapinode.js
  7. +6 −5 lib/utils/index.js
View
@@ -45,7 +45,7 @@ exports.load = function(options,callback){
if(err) return callback(err);
buildDOM(body,options.engine,options.url,callback);
});
-}
+};
/**
* Check if we should follow the redirect `code`.
View
@@ -71,25 +71,20 @@ function scrapDescription(window){
});
}
return descriptions;
-};
+}
/**
* Helpers for `scrapImage` function
*/
-var validExtension = (function(){
- var extensionsImage = {
- gif : false
- };
+var ENUM_INVALID_EXTENSIONS = {
+ gif : false
+};
- return function(src){
- var extension = src.split('.').pop();
- if(extensionsImage[extension] === false){
- return false;
- }
- return true;
- }
-})();
+function isValidExtension(src){
+ var isValid = ENUM_INVALID_EXTENSIONS[extension] === false ? false : true;
+ return isValid;
+}
/**
*
@@ -104,7 +99,7 @@ function scrapImage(window){
var title = scrapTitle(window);
var addToThumbs = function(image,beginning){
var src = $(image).attr('src');
- if(src && validExtension(src) ){
+ if(src && isValidExtension(src) ){
src = utils.toURL(src,url);
if(beginning){
thumbs.unshift(src);
@@ -114,7 +109,7 @@ function scrapImage(window){
}else if(src){
thumbsRejected.push(src);
}
- }
+ };
// Open Graph protocol by Facebook: <meta property="og:image" content="(*)"/>
$('meta').each(function(){
var property = $(this).attr('property');
@@ -147,10 +142,10 @@ function scrapImage(window){
// Leave this test alone
// the selector 'img[alt="title"]' will not work if the title is like LG 42PT35342" PLASMA TV. Escaping issues.
// Image where the title of the page is equal to the content of the alt attribute of the image tag.
- if( alt === title){
+ if(alt === title){
addToThumbs(this,true);
}else{
- addToThumbs(this)
+ addToThumbs(this);
}
});
}
@@ -1,4 +1,10 @@
/**
+ * Module dependencies
+ */
+
+var util = require('util');
+
+/**
* Expose `ScrapinodeError`
*/
@@ -19,4 +25,4 @@ function ScrapinodeError(message){
this.message = message;
}
-ScrapinodeError.prototype.__proto__ = Error.prototype;
+util.inherits(ScrapinodeError,Error);
View
@@ -41,4 +41,4 @@ function Route(path,content,operation){
Route.prototype.match = function(url,content){
return this.path.test(url) && this.content.test(content);
-}
+};
View
@@ -33,7 +33,7 @@ function Router(){
Router.prototype.addRoute = function(route){
this.routes.push(route);
return this;
-}
+};
/**
* Find the relevant operation for the given `url` and `content` expected
@@ -71,4 +71,4 @@ Router.prototype.dispatch = function(url,content,from){
}
};
return defaultResult;
-}
+};
View
@@ -54,7 +54,7 @@ scrapinode.createScraper = function (options,callback){
var scraper = new Scraper(options.url,window,router);
callback(err,scraper);
});
-}
+};
/**
* Add the given `operation` in the router for the given `path` and `content`
@@ -70,7 +70,7 @@ scrapinode.createScraper = function (options,callback){
scrapinode.use = function(path,content,operation){
router.addRoute(new Route(path,content,operation));
return scrapinode;
-}
+};
/**
* Add all given `routes` caracterized by a `path`, a `content` and an `operation` in the `router`
@@ -89,7 +89,7 @@ scrapinode.useAll = function(routes){
router.addRoute(new Route(route.path,route.content,route.operation));
});
return scrapinode;
-}
+};
/**
* Expose default routes for the contents "title", "descriptions", "videos", "images"
@@ -100,4 +100,4 @@ scrapinode.useAll = function(routes){
scrapinode.defaults = function(){
return defaults;
-}
+};
View
@@ -22,7 +22,7 @@ exports.getWebsiteName = getWebsiteName;
*/
function isURL(path) {
- var regex = /(https?:)?\/\/([-\w\.]+)+/i;
+ var regex = /(https?:)?\/\/([\-\w\.]+)+/i;
return regex.test(path);
}
@@ -43,7 +43,7 @@ function toURL(path,uri){
if( path.charAt(0) === '/'){
absolutePath = explodeURL.protocol + '//' + explodeURL.host + path;
}else{
- var explodePathname = explodeURL.pathname.split('/')
+ var explodePathname = explodeURL.pathname.split('/');
var pathname = explodePathname.slice(0,explodePathname.length - 1).join('/');
absolutePath = explodeURL.protocol + '//' + (explodeURL.host + '/' +pathname + '/' + path).replace('\/\/','/','g');
}
@@ -85,17 +85,18 @@ function inline(text){
function getWebsiteName(uri){
var hostname = url.parse(uri).hostname;
+ var name = '';
if(hostname){
var subdomains = domains;
var components = hostname.split('.');
for(var i = components.length -1 ; i >= 0; i-- ){
if(subdomains[components[i]]){
- subdomains = subdomains[components[i]]
+ subdomains = subdomains[components[i]];
}else{
- var name = components[i];
+ name = components[i];
break;
}
}
}
- return name || '';
+ return name;
}

0 comments on commit b2c4e9a

Please sign in to comment.