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.11.2 to 1.11.3

14

lib/index.js

@@ -46,4 +46,4 @@ var Mehdown;

var preceding = text.substring(0, arguments[2]);
var insideTagAttrRegex = /<(?!\/)[^>]+(?!>)$/g;
var insideAnchorTagRegex = /<a[^>]*>(?!<\/a>)$/g;
var insideTagAttrRegex = /<[^\/][^>]+$/g;
var insideAnchorTagRegex = /<a[^>]*>(?:(?!<\/a>).)*$/g;

@@ -56,3 +56,3 @@ // use the correct protocol if href contains baseUrl domain

// inside tag attr or anchor tag, abort
if (preceding.match(insideTagAttrRegex) || preceding.match(insideAnchorTagRegex)) {
if (insideTagAttrRegex.test(preceding) || insideAnchorTagRegex.test(preceding)) {
return url;

@@ -78,8 +78,8 @@ }

var username = arguments[2];
var preceding = text.substring(0, arguments[3]);
var insideTagAttrRegex = /<(?!\/)[^>]+(?!>)$/g;
var insideAnchorTagRegex = /<a[^>]*>.+(?!<\/a>)$/g;
var preceding = text.substring(0, arguments[3]) + precedingNonWord;
var insideTagAttrRegex = /<[^\/][^>]+$/g;
var insideAnchorTagRegex = /<a[^>]*>(?:(?!<\/a>).)*$/g;
// inside tag attr or anchor tag, abort
if (preceding.match(insideTagAttrRegex) || preceding.match(insideAnchorTagRegex)) {
if (insideTagAttrRegex.test(preceding) || insideAnchorTagRegex.test(preceding)) {
return precedingNonWord + '@' + username;

@@ -86,0 +86,0 @@ }

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

},
"version": "1.11.2"
"version": "1.11.3"
}

@@ -114,21 +114,38 @@ var assert = require('assert');

it('already linked domain', function() {
var text = mehdown.parse('<p><a href="http://example.com">http://example.com</a> and example.com</p>');
assert.equal(text, '<p><a rel="nofollow" target="_blank" href="http://example.com">http://example.com</a> and <a rel="nofollow" target="_blank" href="http://example.com">example.com</a></p>');
it('email address', function() {
var text = mehdown.parse('<p>email me at whatever@somewhere.com if you are not a meanie.</p>');
assert.equal(text, '<p>email me at <a rel="nofollow" target="_blank" href="mailto:whatever@somewhere.com">whatever@somewhere.com</a> if you are not a meanie.</p>');
});
});
it('already linked domain with additional anchor text', function() {
var text = mehdown.parse('<p><a href="http://example.com">example.com is the coolest site</a></p>');
assert.equal(text, '<p><a rel="nofollow" target="_blank" href="http://example.com">example.com is the coolest site</a></p>');
describe('already linked url', function() {
it('<p><a href="http://example.com">http://example.com</a></p>', function() {
var text = mehdown.parse('<p><a href="http://example.com">http://example.com</a></p>');
assert.equal(text, '<p><a rel="nofollow" target="_blank" href="http://example.com">http://example.com</a></p>');
});
it('domain is in tag attribute', function() {
it('<p><a href="http://example.com">see http://example.com here</a></p>', function() {
var text = mehdown.parse('<p><a href="http://example.com">see http://example.com here</a></p>');
assert.equal(text, '<p><a rel="nofollow" target="_blank" href="http://example.com">see http://example.com here</a></p>');
});
it('<p><a href="http://example.com">example.com</a></p>', function() {
var text = mehdown.parse('<p><a href="http://example.com">example.com</a></p>');
assert.equal(text, '<p><a rel="nofollow" target="_blank" href="http://example.com">example.com</a></p>');
});
it('<p><a href="http://example.com">see example.com here</a></p>', function() {
var text = mehdown.parse('<p><a href="http://example.com">see example.com here</a></p>');
assert.equal(text, '<p><a rel="nofollow" target="_blank" href="http://example.com">see example.com here</a></p>');
});
it('<p><a href="http://example.com">leavemealone.com</a> but linkme.com</p>', function() {
var text = mehdown.parse('<p><a href="http://example.com">leavemealone.com</a> but linkme.com</p>');
assert.equal(text, '<p><a rel="nofollow" target="_blank" href="http://example.com">leavemealone.com</a> but <a rel="nofollow" target="_blank" href="http://linkme.com">linkme.com</a></p>');
});
it('<p><a href="http://example.com" title="Go To Example.com">example.com</a></p>', function() {
var text = mehdown.parse('<p><a href="http://example.com" title="Go To Example.com">example.com</a></p>');
assert.equal(text, '<p><a rel="nofollow" target="_blank" href="http://example.com" title="Go To Example.com">example.com</a></p>');
});
it('email address', function() {
var text = mehdown.parse('<p>email me at whatever@somewhere.com if you are not a meanie.</p>');
assert.equal(text, '<p>email me at <a rel="nofollow" target="_blank" href="mailto:whatever@somewhere.com">whatever@somewhere.com</a> if you are not a meanie.</p>');
});
});

@@ -176,2 +193,7 @@

it('<p>@username @othername</p>', function() {
var text = mehdown.parse('<p>@username @othername</p>');
assert.equal(text, '<p><a href="https://mediocre.com/@username">@username</a> <a href="https://mediocre.com/@othername">@othername</a></p>');
});
it('abc @username 123', function() {

@@ -178,0 +200,0 @@ var text = mehdown.parse('abc @username 123');

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