Skip to content

Commit

Permalink
extend get function to handle path contain quote (#336)
Browse files Browse the repository at this point in the history
* extend get function to handle path contain quote

* Use const instead of updating key value

---------

Co-authored-by: shenyang <[email protected]>
Co-authored-by: Ray Epps <[email protected]>
Co-authored-by: Ray Epps <[email protected]>
  • Loading branch information
4 people authored Feb 21, 2024
1 parent 342924b commit 2d6c10a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion cdn/radash.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -709,11 +709,12 @@ const omit = (obj, keys2) => {
const get = (value, path, defaultValue) => {
const segments = path.split(/[\.\[\]]/g);
let current = value;
for (const key of segments) {
for (let key of segments) {
if (current === null)
return defaultValue;
if (current === void 0)
return defaultValue;
key = key.replace(/['"]/g, "");
if (key.trim() === "")
continue;
current = current[key];
Expand Down
3 changes: 2 additions & 1 deletion cdn/radash.js
Original file line number Diff line number Diff line change
Expand Up @@ -712,11 +712,12 @@ var radash = (function (exports) {
const get = (value, path, defaultValue) => {
const segments = path.split(/[\.\[\]]/g);
let current = value;
for (const key of segments) {
for (let key of segments) {
if (current === null)
return defaultValue;
if (current === void 0)
return defaultValue;
key = key.replace(/['"]/g, "");
if (key.trim() === "")
continue;
current = current[key];
Expand Down
Loading

0 comments on commit 2d6c10a

Please sign in to comment.