mirror of
https://github.com/denoland/deno.git
synced 2025-02-01 12:16:11 -05:00
fix(std/toml): parser error with inline comments (#6942)
This commit is contained in:
parent
e9d713c007
commit
d615ebefe2
3 changed files with 4 additions and 3 deletions
3
std/encoding/testdata/boolean.toml
vendored
3
std/encoding/testdata/boolean.toml
vendored
|
@ -1,3 +1,4 @@
|
||||||
[boolean] # i hate comments
|
[boolean] # i hate comments
|
||||||
bool1 = true
|
bool1 = true
|
||||||
bool2 = false
|
bool2 = false
|
||||||
|
bool3 = true # I love comments
|
|
@ -280,7 +280,7 @@ class Parser {
|
||||||
return dataString.slice(0, endOfString);
|
return dataString.slice(0, endOfString);
|
||||||
}
|
}
|
||||||
|
|
||||||
const m = /(?:|\[|{|).*(?:|\]||})\s*[^#]/g.exec(dataString);
|
const m = /(?:|\[|{).*(?:|\]|})\s*^((?!#).)*/g.exec(dataString);
|
||||||
if (m) {
|
if (m) {
|
||||||
return m[0].trim();
|
return m[0].trim();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -48,7 +48,7 @@ Deno.test({
|
||||||
Deno.test({
|
Deno.test({
|
||||||
name: "[TOML] Boolean",
|
name: "[TOML] Boolean",
|
||||||
fn(): void {
|
fn(): void {
|
||||||
const expected = { boolean: { bool1: true, bool2: false } };
|
const expected = { boolean: { bool1: true, bool2: false, bool3: true } };
|
||||||
const actual = parseFile(path.join(testFilesDir, "boolean.toml"));
|
const actual = parseFile(path.join(testFilesDir, "boolean.toml"));
|
||||||
assertEquals(actual, expected);
|
assertEquals(actual, expected);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue