Skip to content

Commit

Permalink
fix image url
Browse files Browse the repository at this point in the history
  • Loading branch information
rockdai committed Nov 10, 2015
1 parent 032b5a7 commit 151a9d0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion crawler.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,20 @@ function onerror(err) {
console.log(err);
}

function fixImagesPath(imgs) {
imgs = imgs || [];
return imgs.map(function (img) {
if (img && img.startsWith('https://')) {
img = img.replace('https://', 'http://');
}
return img;
});
}

function* handleTopic(topic) {
topic = topic || {};
let topicId = topic.id;
let imgs = _.pluck(topic.photos, 'alt');
let imgs = fixImagesPath(_.pluck(topic.photos, 'alt'));

let doc = yield Post.findOne({id: topicId}).exec();
if (doc) {
Expand Down

0 comments on commit 151a9d0

Please sign in to comment.