npm / ini

An ini parser/serializer in JavaScript
ISC License
770 stars 206 forks source link

[BUG] Single quotes removed from values #242

Open simoneb opened 9 months ago

simoneb commented 9 months ago

Is there an existing issue for this?

Current Behavior

Decoding then encoding (without further transformation) a file like this:

ActiveIndex = '0'
MaximizedFlag = '1911'
ProductVersion = '14.0.25793.400'
Version = '1'
WindowCount = '1'

Turns it into this:

ActiveIndex=0
MaximizedFlag=1911
ProductVersion=14.0.25793.400
Version=1
WindowCount=1

It basically removed the single quotes around the values, thereby causing a compatibility issue with the software that is supposed to open this file.

Expected Behavior

Single quotes are not removed from values

Steps To Reproduce

import fs from "fs";
import ini from "ini";

const input = `ActiveIndex = '0'
MaximizedFlag = '1911'
ProductVersion = '14.0.25793.400'
Version = '1'
WindowCount = '1'`

const data = ini.parse(input);

// prints the values without quotes
console.log(ini.stringify(data));

Environment

underwoodsolartechx commented 3 months ago

bug

underwoodsolartechx commented 3 months ago

fixed

underwoodsolartechx commented 3 months ago

import fs from "fs"; import ini from "ini";

const input = ActiveIndex = '0' MaximizedFlag = '1911' ProductVersion = '14.0.25793.400' Version = '1' WindowCount = '1'

const data = ini.parse(input);

// prints the values without quotes console.log(ini.stringify(data));

underwoodsolartechx commented 3 months ago

ActiveIndex = '0' MaximizedFlag = '1911' ProductVersion = '14.0.25793.400' Version = '1' WindowCount = '1'