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

impro

Package Overview
Dependencies
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

impro - npm Package Compare versions

Comparing version 0.6.1 to 0.7.0

src/queryString.js

2

package.json
{
"name": "impro",
"version": "0.6.1",
"version": "0.7.0",
"description": "Image processing engine",

@@ -5,0 +5,0 @@ "author": "Andreas Lind <andreaslindpetersen@gmail.com>",

@@ -64,7 +64,5 @@ const _ = require('lodash');

if (operations) {
if (typeof operations === 'string') {
operations = this.parse(operations).operations;
} else if (!Array.isArray(operations)) {
if (!Array.isArray(operations)) {
throw new Error(
'Pipeline creation can only be supplied an operations array or string'
'Pipeline creation can only be supplied an operations array'
);

@@ -171,81 +169,2 @@ }

}
parse(queryString, allowOperation) {
allowOperation =
typeof allowOperation === 'function'
? allowOperation
: this.allowOperation;
var keyValuePairs = queryString.split('&');
var operations = [];
var leftOverQueryStringFragments = [];
var consumedQueryStringFragments = [];
keyValuePairs.forEach(function(keyValuePair) {
var matchKeyValuePair = keyValuePair.match(/^([^=]+)(?:=(.*))?/);
if (matchKeyValuePair) {
var operationName = decodeURIComponent(matchKeyValuePair[1]);
// Split by non-URL encoded comma or plus:
var operationArgs = matchKeyValuePair[2]
? matchKeyValuePair[2].split(/[+,]/).map(function(arg) {
arg = decodeURIComponent(arg);
if (/^\d+$/.test(arg)) {
return parseInt(arg, 10);
} else if (arg === 'true') {
return true;
} else if (arg === 'false') {
return false;
} else {
return arg;
}
})
: [];
if (operationName in this.engineByName) {
// engines accept only a single options object argument, so
// in cases where the query string contains options intended
// for the engine itself we must put them in an object which
// we can then pass as that only supported argument
const engineOptions = {};
operationArgs.forEach(arg => {
if (typeof arg !== 'string' || arg.indexOf('=') === -1) return;
const [optionKey, optionValue] = arg.split('=');
if (this.restrictedOptions.includes(optionKey)) return;
engineOptions[optionKey] = optionValue;
});
if (Object.keys(engineOptions).length > 0) {
operationArgs = [engineOptions];
} else {
operationArgs = [];
}
}
// empty resize args must be passed to engines as null
if (operationName === 'resize') {
operationArgs = operationArgs.map(arg => arg || null);
}
if (
!this.isValidOperation(operationName, operationArgs) ||
(typeof allowOperation === 'function' &&
!allowOperation(operationName, operationArgs))
) {
leftOverQueryStringFragments.push(keyValuePair);
} else {
operations.push({
name: operationName,
args: operationArgs
});
consumedQueryStringFragments.push(keyValuePair);
}
}
}, this);
return {
operations: operations,
leftover: leftOverQueryStringFragments.join('&'),
consumed: consumedQueryStringFragments.join('&')
};
}
};

@@ -18,1 +18,2 @@ const Impro = require('./Impro');

module.exports.engines = engines;
module.exports.queryString = require('./queryString');
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