memserver
Advanced tools
Comparing version 2.3.0 to 2.3.1
@@ -50,23 +50,19 @@ "use strict"; | ||
function tryConvertingJSONStringToObject(string) { | ||
let object; | ||
try { | ||
object = JSON.parse(string); | ||
let object = JSON.parse(string); | ||
if (typeof object === "object" && object !== null) { | ||
return object; | ||
} | ||
} | ||
catch (e) { | ||
return false; | ||
catch (error) { | ||
} | ||
if (typeof object === "object" && object !== null) { | ||
return object; | ||
} | ||
return false; | ||
} | ||
function tryConvertingQueryStringToObject(queryString) { | ||
let result = {}; | ||
let entries = new URLSearchParams(queryString); | ||
for (const [key, value] of entries) { // each 'entry' is a [queryParamKey, queryParamValue] tupple | ||
result[key] = value; | ||
let entries = Array.from(new URLSearchParams(queryString)); | ||
if (entries.length > 0) { | ||
return entries.reduce((result, entry) => { | ||
result[entry[0]] = entry[1]; | ||
return result; | ||
}, {}); | ||
} | ||
if (Object.keys(result).length > 0) { | ||
return result; | ||
} | ||
} | ||
@@ -73,0 +69,0 @@ function nilifyStrings(value) { |
{ | ||
"name": "memserver", | ||
"version": "2.3.0", | ||
"version": "2.3.1", | ||
"description": "in-memory database/ORM and http mock server you can run in-browser and node environments. Built for large frontend teams, fast tests and rapid prototyping", | ||
@@ -5,0 +5,0 @@ "author": "Izel Nakri", |
@@ -52,25 +52,21 @@ import chalk from "ansi-colors"; | ||
function tryConvertingJSONStringToObject(string) { | ||
let object; | ||
try { | ||
object = JSON.parse(string); | ||
} catch (e) { | ||
return false; | ||
} | ||
let object = JSON.parse(string); | ||
if (typeof object === "object" && object !== null) { | ||
return object; | ||
if (typeof object === "object" && object !== null) { | ||
return object; | ||
} | ||
} catch(error) { | ||
} | ||
return false; | ||
} | ||
function tryConvertingQueryStringToObject(queryString) { | ||
let result = {}; | ||
let entries = new URLSearchParams(queryString); | ||
for (const [key, value] of entries) { // each 'entry' is a [queryParamKey, queryParamValue] tupple | ||
result[key] = value; | ||
} | ||
let entries = Array.from(new URLSearchParams(queryString)); | ||
if (Object.keys(result).length > 0) { | ||
return result; | ||
if (entries.length > 0) { | ||
return entries.reduce((result, entry) => { | ||
result[entry[0]] = entry[1]; | ||
return result; | ||
}, {}); | ||
} | ||
@@ -77,0 +73,0 @@ } |
Sorry, the diff of this file is too big to display
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
496283
13294