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

Patch method breaks the array of strings #10

Open
antoniofarina opened this issue Jan 15, 2020 · 0 comments
Open

Patch method breaks the array of strings #10

antoniofarina opened this issue Jan 15, 2020 · 0 comments

Comments

@antoniofarina
Copy link

antoniofarina commented Jan 15, 2020

Hi,
consider the code below.
As you can see, altering the disableLanguages array (removing an item) the patch method breaks the disableLanguages array

NOTE

the input is a part of a longer config file but, consider that I have checked the issue on the whole file. I also tried to change the spacing between elements in the disableLanguages array (["he", "hu", "zh", "nb", "da", "ro", "fi"], ['he', 'hu', 'zh', 'nb', 'da', 'ro', 'fi'], ["he","hu","zh","nb","da","ro","fi"], ['he','hu','zh','nb','da','ro','fi'], ... and so on ) with the same result

let tomlFileContent= 'baseUrl = "https://example.com/"
languageCode = "en-us"
languageLang = "en"
title = "this is the title"
DefaultContentLanguage = "en"
disableLanguages = ["he", "hu", "zh", "nb", "da", "ro", "fi"]'

value= parse(tomlFileContent)

console.log (value.disableLanguages)
## output  [ "he", "hu", "zh", "nb", "da", "ro", "fi" ]
for (var i = 0; i < value.disableLanguages.length; i++) {
        if (value.disableLanguages[i] === 'he') {
            value.disableLanguages.splice(i, 1);
            i--;
        }
    }
console.log (value.disableLanguages)
## output  ["hu", "zh", "nb", "da", "ro", "fi"]

console.log (patch(tomlFileContent, value))
### output 
baseUrl = "https://example.com/"
languageCode = "en-us"
languageLang = "en"
title = "this is the title"
DefaultContentLanguage = "en"
disableLanguages = ["he", "hu", "zh", "nb", "da", "ro", "fi"    <---- BROKEN !!!!
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