Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug in src/util/helpers.js merge function for case with an Array field #750

Open
tbarabanov opened this issue Jan 18, 2024 · 0 comments
Open

Comments

@tbarabanov
Copy link

my custom imposter config

{
   "port":"8029",
   "protocol":"custom",
   "name":"pike",
   "array": ["a", "b"]
}

mb code

function merge (defaults, overrides) {
    const result = clone(defaults);
    Object.keys(overrides).forEach(key => {
        if (typeof overrides[key] === 'object' && overrides[key] !== null) {
            result[key] = merge(result[key] || {}, overrides[key]);
        }
        else {
            result[key] = overrides[key];
        }
    });
    return result;
}

since typeof Array is object imposter will get wrong args:

{
   "port":"8029",
   "callbackURLTemplate":"http://localhost:8025/imposters/:port/_requests",
   "loglevel":"debug",
   "allowInjection":true,
   ...
   "array":{"0":"a", "1":"b"}
}

Expected behaviour

mb must leave arrays as is

Actual behaviour

mb breaks the config

mb version 2.7.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant