diff --git a/package.json b/package.json index d8e7d28..bf182d9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ini-decode", - "version": "1.0.3", + "version": "1.0.4", "description": "", "main": "dist/index.js", "types": "typing/index.d.ts", diff --git a/src/index.ts b/src/index.ts index f2eb593..c8f8ec9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,7 +8,7 @@ function parseBase(_content: string | Buffer) { //此函数用于加入值到结果 (_content + '') //删除注释 - .replace(/[;#][\s\S]*?\r?\n/g, '\n') + .replace(/[;#][\s\S]*?\r?$/gm, '') //按行分割 .split(/\r?\n/) //trim + filter diff --git a/test/test.ini b/test/test.ini index e3c77d9..13c8bff 100644 --- a/test/test.ini +++ b/test/test.ini @@ -1,19 +1,21 @@ -[user.id1] -id = 1 -name = Mimi -gender = female -isAdmin = true +# 数据库配置 +[database] +# 默认数据库 +default = mysql +# 是否打印日志 +logging = false +# 是否自动建表或更新表 +synchronize = true -[user.id2] -id = 2 -name = Mimi -gender = female -isAdmin = true +# mysql数据库配置 +[mysql] +type = mysql +host = 127.0.0.1 +port = 3306 +username = root +password = 123456 +database = shipwin-dev-v2 -[password] -# 注释 -admin = 123 -login = "456" -test[] = 789 -test[] = 789 -test2 = 123,456,"789" +# 可以有其他数据库配置 +# [] +# = \ No newline at end of file diff --git a/test/test.ts b/test/test.ts index fa66e28..f17cb26 100644 --- a/test/test.ts +++ b/test/test.ts @@ -3,4 +3,4 @@ import { decode } from '../src' const content = fs.readFileSync(__dirname + '/test.ini') const res = decode(content) -console.log(res) \ No newline at end of file +console.log(res.json) \ No newline at end of file