@janiscommerce/api
Advanced tools
Comparing version 6.5.2 to 6.6.0
@@ -9,2 +9,6 @@ # Changelog | ||
## [6.6.0] - 2022-11-18 | ||
### Changed | ||
- Now data received is trimmed to avoid empty spaces before and after for strings | ||
## [6.5.2] - 2022-07-15 | ||
@@ -11,0 +15,0 @@ ### Added |
@@ -8,4 +8,5 @@ 'use strict'; | ||
const cloneObj = require('lodash.clonedeep'); | ||
const Fetcher = require('./fetcher'); | ||
const { isObject } = require('./utils'); | ||
const { isObject, trimObjectValues } = require('./utils'); | ||
@@ -40,7 +41,6 @@ const API = require('./api'); | ||
this._validateRequest(request); | ||
this.endpoint = request.endpoint.replace(/^\/?(api\/)?/i, ''); | ||
this.method = (request.method || 'get').toLowerCase(); | ||
this.data = request.data || {}; | ||
this.pristineData = request.data && { ...request.data }; | ||
this.data = trimObjectValues(request.data && cloneObj(request.data)); | ||
this.pristineData = request.data; | ||
Object.freeze(this.pristineData); | ||
@@ -47,0 +47,0 @@ this.rawData = request.rawData; |
@@ -32,5 +32,23 @@ 'use strict'; | ||
const trimObjectValues = value => { | ||
if(typeof value !== 'object' || !value) | ||
return value; | ||
Object.keys(value).forEach(k => { | ||
if((typeof value[k] === 'string')) | ||
value[k] = value[k].trim(); | ||
if(typeof value[k] === 'object' && value[k] !== null) | ||
value[k] = trimObjectValues(value[k]); | ||
}); | ||
return value; | ||
}; | ||
module.exports = { | ||
isObject, | ||
omitRecursive | ||
omitRecursive, | ||
trimObjectValues | ||
}; |
{ | ||
"name": "@janiscommerce/api", | ||
"version": "6.5.2", | ||
"version": "6.6.0", | ||
"description": "A package for managing API from any origin", | ||
@@ -31,3 +31,3 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"eslint": "^8.8.0", | ||
"eslint": "^8.27.0", | ||
"eslint-config-airbnb-base": "^13.2.0", | ||
@@ -45,4 +45,5 @@ "eslint-plugin-import": "^2.25.3", | ||
"@janiscommerce/events": "^0.1.0", | ||
"@janiscommerce/log": "^3.5.1", | ||
"@janiscommerce/superstruct": "^1.2.0", | ||
"@janiscommerce/log": "^3.6.0", | ||
"@janiscommerce/superstruct": "^1.2.1", | ||
"lodash.clonedeep": "^4.5.0", | ||
"lodash.omit": "4.5.0", | ||
@@ -49,0 +50,0 @@ "uuid": "^8.3.2" |
@@ -17,1 +17,2 @@ /** | ||
}, exclude: string | Array<string>): any; | ||
export function trimObjectValues(value: any): any; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41138
949
7
+ Addedlodash.clonedeep@^4.5.0
+ Addedlodash.clonedeep@4.5.0(transitive)
Updated@janiscommerce/log@^3.6.0