New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fetch-reddit

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fetch-reddit - npm Package Compare versions

Comparing version 0.0.9 to 0.0.10

7

CHANGELOG.md

@@ -7,2 +7,9 @@ # Change Log

#### [v0.0.10](https://github.com/CookPete/fetch-reddit/compare/v0.0.9...v0.0.10)
> 22 January 2016
* Add thumbnails for all YouTube links [`6b9f745`](https://github.com/CookPete/fetch-reddit/commit/6b9f7454ce053f93607b7b6a68930897b72cc2ac)
* Remove markdown bold/italics from titles [`db446ac`](https://github.com/CookPete/fetch-reddit/commit/db446ac81b7d96a8c30938661037ebbbc6fde82f)
#### [v0.0.9](https://github.com/CookPete/fetch-reddit/compare/v0.0.8...v0.0.9)

@@ -9,0 +16,0 @@ > 11 January 2016

27

lib/index.js

@@ -17,2 +17,3 @@ 'use strict';

var INFER_TITLE_MAX_LENGTH = 128; // Max length of remaining text to use as a title for a link
var MATCH_YOUTUBE_URL = /^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/;

@@ -134,5 +135,5 @@ var KIND_COMMENT = 't1';

subreddit: post.subreddit,
thumbnail: getThumbnail(post),
permalink: getPermalink(post),
// Post-specific fields
thumbnail: post.thumbnail,
num_comments: post.num_comments

@@ -155,3 +156,3 @@ };

id: post.id + ':' + offset,
title: title,
title: removeMarkdown(title),
url: url,

@@ -162,2 +163,3 @@ created: new Date(post.created_utc * 1000),

subreddit: post.subreddit,
thumbnail: getThumbnail(post, url),
permalink: getPermalink(post, path),

@@ -181,2 +183,23 @@ // Comment-specific fields

return REDDIT_URL + path + slash + post.id;
}
function getThumbnail(post) {
var url = arguments.length <= 1 || arguments[1] === undefined ? post.url : arguments[1];
if (post.thumbnail) {
return post.thumbnail;
}
var matchYouTube = url.match(MATCH_YOUTUBE_URL);
if (matchYouTube) {
var id = matchYouTube[1];
return 'http://img.youtube.com/vi/' + id + '/default.jpg';
}
return null;
}
// Remove markdown bold/italics
// From https://github.com/stiang/remove-markdown
function removeMarkdown(string) {
if (!string) return string;
return string.replace(/([\*_]{1,3})(\S.*?\S)\1/g, '$2');
}

2

package.json
{
"name": "fetch-reddit",
"version": "0.0.9",
"version": "0.0.10",
"description": "Easily fetch links from Reddit subs and threads",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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