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

mehdown

Package Overview
Dependencies
Maintainers
1
Versions
134
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mehdown - npm Package Compare versions

Comparing version 1.5.1 to 1.6.0

12

lib/index.js

@@ -5,3 +5,3 @@ var Mehdown;

Mehdown = exports;
Mehdown.baseUrl = process.env.NODE_ENV !== 'production' ? 'http://localhost:8000' : 'https://mediocre.com';
Mehdown.baseUrl = process.env.NODE_ENV !== 'production' ? 'http://127.0.0.1:8000' : 'https://mediocre.com';
}

@@ -60,2 +60,6 @@ else {

// Images
var imgRegExp = /<a href="(https?:\/\/([-\w%\/\.]+\.(?:jpg|jpeg|gif|png)(?:\?[-\+=&;%@\.\w]+)?))">\1<\/a>/gi;
text = text.replace(imgRegExp, Mehdown.img('$2'));
// Anchors

@@ -83,3 +87,3 @@ var anchorRegExp = new RegExp('<a[^>]*>([^<]+)</a>', 'gi');

if(href.indexOf('href="/') === 0 || href.indexOf('mediocre.com') === 0 || href.indexOf('localhost') === 0) {
if(href.indexOf('href="/') === 0 || href.indexOf('mediocre.com') === 0 || href.indexOf('localhost') === 0 || href.indexOf('127.0.0.1') === 0) {
isLocal = true;

@@ -101,2 +105,6 @@ };

Mehdown.img = function(url) {
return '<img src="//' + url + '" />';
};
Mehdown.spoiler = function(spoiler) {

@@ -103,0 +111,0 @@ return '<span class="spoiler">' + spoiler + '</span>';

2

package.json

@@ -13,3 +13,3 @@ {

},
"version": "1.5.1"
"version": "1.6.0"
}

@@ -42,5 +42,5 @@ var assert = require('assert');

it('localhost href', function() {
var text = mehdown.parse('<p><a href="http://localhost:8000/path">path</a></p>');
assert.equal(text, '<p><a href="http://localhost:8000/path">path</a></p>');
it('127.0.0.1 href', function() {
var text = mehdown.parse('<p><a href="http://127.0.0.1:8000/path">path</a></p>');
assert.equal(text, '<p><a href="http://127.0.0.1:8000/path">path</a></p>');
});

@@ -54,2 +54,29 @@

describe('images', function() {
it('.jpg', function() {
var text = mehdown.parse('<p><a href="http://i.imgur.com/9oiY1aO.jpg">http://i.imgur.com/9oiY1aO.jpg</a></p>');
assert.equal(text, '<p><img src="//i.imgur.com/9oiY1aO.jpg" /></p>');
});
it('.gif', function() {
var text = mehdown.parse('<p><a href="http://www.bubblews.com/assets/images/news/225123606_1387763263.gif">http://www.bubblews.com/assets/images/news/225123606_1387763263.gif</a></p>');
assert.equal(text, '<p><img src="//www.bubblews.com/assets/images/news/225123606_1387763263.gif" /></p>');
});
it('.png', function() {
var text = mehdown.parse('<p><a href="http://fc09.deviantart.net/fs44/f/2009/067/a/a/Green_Humming_Bird_PNG_by_pixievamp_stock.png">http://fc09.deviantart.net/fs44/f/2009/067/a/a/Green_Humming_Bird_PNG_by_pixievamp_stock.png</a></p>');
assert.equal(text, '<p><img src="//fc09.deviantart.net/fs44/f/2009/067/a/a/Green_Humming_Bird_PNG_by_pixievamp_stock.png" /></p>');
});
it('.jpg with long url and query string', function() {
var text = mehdown.parse('<p><a href="http://images.nationalgeographic.com/wpf/media-live/photos/000/770/cache/payunia-volcano-argentina_77070_990x742.jpg?01AD=3jGr9FxQ0BANJabwfZqq7ejovySQ1dQw8kO0oygkZlKrsJUzb-jUb7Q&01RI=1E4070A575D8186&01NA=na">http://images.nationalgeographic.com/wpf/media-live/photos/000/770/cache/payunia-volcano-argentina_77070_990x742.jpg?01AD=3jGr9FxQ0BANJabwfZqq7ejovySQ1dQw8kO0oygkZlKrsJUzb-jUb7Q&01RI=1E4070A575D8186&01NA=na</a></p>');
assert.equal(text, '<p><img src="//images.nationalgeographic.com/wpf/media-live/photos/000/770/cache/payunia-volcano-argentina_77070_990x742.jpg?01AD=3jGr9FxQ0BANJabwfZqq7ejovySQ1dQw8kO0oygkZlKrsJUzb-jUb7Q&01RI=1E4070A575D8186&01NA=na" /></p>');
});
it('.png with %20 (space) in url', function() {
var text = mehdown.parse('<p><a href="http://izaak.jellinek.com/tuxes/images/big%20tux.png">http://izaak.jellinek.com/tuxes/images/big%20tux.png</a></p>');
assert.equal(text, '<p><img src="//izaak.jellinek.com/tuxes/images/big%20tux.png" /></p>');
});
});
describe('strikethrough', function() {

@@ -65,3 +92,3 @@ it('~~', function() {

var text = mehdown.parse('@username');
assert.equal(text, '<a href="http://localhost:8000/@username">@username</a>');
assert.equal(text, '<a href="http://127.0.0.1:8000/@username">@username</a>');
});

@@ -71,3 +98,3 @@

var text = mehdown.parse('abc @username 123');
assert.equal(text, 'abc <a href="http://localhost:8000/@username">@username</a> 123');
assert.equal(text, 'abc <a href="http://127.0.0.1:8000/@username">@username</a> 123');
});

@@ -77,3 +104,3 @@

var text = mehdown.parse('abc @username1 notausername@notausername @username2 123');
assert.equal(text, 'abc <a href="http://localhost:8000/@username1">@username1</a> notausername@notausername <a href="http://localhost:8000/@username2">@username2</a> 123');
assert.equal(text, 'abc <a href="http://127.0.0.1:8000/@username1">@username1</a> notausername@notausername <a href="http://127.0.0.1:8000/@username2">@username2</a> 123');
});

@@ -80,0 +107,0 @@ });

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