Socket
Socket
Sign inDemoInstall

medium-editor

Package Overview
Dependencies
Maintainers
6
Versions
125
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

medium-editor - npm Package Compare versions

Comparing version 5.22.0 to 5.22.1

2

package.json
{
"name": "medium-editor",
"version": "5.22.0",
"version": "5.22.1",
"author": "Davi Ferreira <hi@daviferreira.com>",

@@ -5,0 +5,0 @@ "contributors": [

@@ -359,8 +359,8 @@ /*global fireEvent, selectElementContents,

it('should change spaces to %20 for a valid url if linkValidation options is set to true', function () {
it('should change spaces to %20 for a valid url if linkValidation option is set to true', function () {
var editor = this.newMediumEditor('.editor', {
anchor: {
linkValidation: true
}
}),
anchor: {
linkValidation: true
}
}),
link,

@@ -386,2 +386,79 @@ anchorExtension = editor.getExtensionByName('anchor'),

it('should not encode an encoded URL if linkValidation option is set to true', function () {
var editor = this.newMediumEditor('.editor', {
anchor: {
linkValidation: true
}
}),
link,
anchorExtension = editor.getExtensionByName('anchor'),
expectedOpts = {
value: 'http://a%20b.com/',
target: '_self'
};
spyOn(editor, 'execAction').and.callThrough();
selectElementContentsAndFire(editor.elements[0]);
anchorExtension.showForm('a%20b.com/');
fireEvent(anchorExtension.getForm().querySelector('a.medium-editor-toolbar-save'), 'click');
expect(editor.execAction).toHaveBeenCalledWith('createLink', expectedOpts);
link = editor.elements[0].querySelector('a');
expect(link).not.toBeNull();
expect(link.href).toBe(expectedOpts.value);
});
it('should encode query params if linkValidation option is set to true', function () {
var editor = this.newMediumEditor('.editor', {
anchor: {
linkValidation: true
}
}),
link,
anchorExtension = editor.getExtensionByName('anchor'),
expectedOpts = {
value: 'http://a.com/?q=http%3A%2F%2Fb.com&q2=http%3A%2F%2Fc.com',
target: '_self'
};
spyOn(editor, 'execAction').and.callThrough();
selectElementContentsAndFire(editor.elements[0]);
anchorExtension.showForm('a.com/?q=http://b.com&q2=http://c.com');
fireEvent(anchorExtension.getForm().querySelector('a.medium-editor-toolbar-save'), 'click');
expect(editor.execAction).toHaveBeenCalledWith('createLink', expectedOpts);
link = editor.elements[0].querySelector('a');
expect(link).not.toBeNull();
expect(link.href).toBe(expectedOpts.value);
});
it('should not encode an encoded query param if linkValidation option is set to true', function () {
var editor = this.newMediumEditor('.editor', {
anchor: {
linkValidation: true
}
}),
link,
anchorExtension = editor.getExtensionByName('anchor'),
expectedOpts = {
value: 'http://a.com/?q=http%3A%2F%2Fb.com&q2=http%3A%2F%2Fc.com',
target: '_self'
};
spyOn(editor, 'execAction').and.callThrough();
selectElementContentsAndFire(editor.elements[0]);
anchorExtension.showForm('a.com/?q=http%3A%2F%2Fb.com&q2=http://c.com');
fireEvent(anchorExtension.getForm().querySelector('a.medium-editor-toolbar-save'), 'click');
expect(editor.execAction).toHaveBeenCalledWith('createLink', expectedOpts);
link = editor.elements[0].querySelector('a');
expect(link).not.toBeNull();
expect(link.href).toBe(expectedOpts.value);
});
it('should not change spaces to %20 if linkValidation is set to false', function () {

@@ -388,0 +465,0 @@ var editor = this.newMediumEditor('.editor', {

@@ -234,2 +234,22 @@ (function () {

ensureEncodedUri: function (str) {
return str === decodeURI(str) ? encodeURI(str) : str;
},
ensureEncodedUriComponent: function (str) {
return str === decodeURIComponent(str) ? encodeURIComponent(str) : str;
},
ensureEncodedParam: function (param) {
var split = param.split('='),
key = split[0],
val = split[1];
return key + (val === undefined ? '' : '=' + this.ensureEncodedUriComponent(val));
},
ensureEncodedQuery: function (queryString) {
return queryString.split('&').map(this.ensureEncodedParam.bind(this)).join('&');
},
checkLinkFormat: function (value) {

@@ -241,4 +261,8 @@ // Matches any alphabetical characters followed by ://

var urlSchemeRegex = /^([a-z]+:)?\/\/|^(mailto|tel|maps):|^\#/i,
// var te is a regex for checking if the string is a telephone number
telRegex = /^\+?\s?\(?(?:\d\s?\-?\)?){3,20}$/;
// telRegex is a regex for checking if the string is a telephone number
telRegex = /^\+?\s?\(?(?:\d\s?\-?\)?){3,20}$/,
split = value.split('?'),
path = split[0],
query = split[1];
if (telRegex.test(value)) {

@@ -248,3 +272,7 @@ return 'tel:' + value;

// Check for URL scheme and default to http:// if none found
return (urlSchemeRegex.test(value) ? '' : 'http://') + encodeURI(value);
return (urlSchemeRegex.test(value) ? '' : 'http://') +
// Ensure path is encoded
this.ensureEncodedUri(path) +
// Ensure query is encoded
(query === undefined ? '' : '?' + this.ensureEncodedQuery(query));
}

@@ -251,0 +279,0 @@ },

@@ -18,3 +18,3 @@ MediumEditor.parseVersionString = function (release) {

// grunt-bump looks for this:
'version': '5.22.0'
'version': '5.22.1'
}).version);
(function (root, factory) {
'use strict';
var isElectron = typeof module === 'object' && process && process.versions && process.versions.electron;
var isElectron = typeof module === 'object' && typeof process !== 'undefined' && process && process.versions && process.versions.electron;
if (!isElectron && typeof module === 'object') {

@@ -5,0 +5,0 @@ module.exports = factory;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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