summaryrefslogtreecommitdiff
path: root/std/encoding
diff options
context:
space:
mode:
Diffstat (limited to 'std/encoding')
-rw-r--r--std/encoding/testdata/string.toml1
-rw-r--r--std/encoding/toml.ts2
-rw-r--r--std/encoding/toml_test.ts2
3 files changed, 4 insertions, 1 deletions
diff --git a/std/encoding/testdata/string.toml b/std/encoding/testdata/string.toml
index 55e3fca34..05f425f11 100644
--- a/std/encoding/testdata/string.toml
+++ b/std/encoding/testdata/string.toml
@@ -31,3 +31,4 @@ trimmed in raw strings.
withApostrophe = "What if it's not?"
withSemicolon = "const message = 'hello world';"
+withHexNumberLiteral = "Prevent bug from stripping string here ->0xabcdef"
diff --git a/std/encoding/toml.ts b/std/encoding/toml.ts
index bd6814ac3..121459dbf 100644
--- a/std/encoding/toml.ts
+++ b/std/encoding/toml.ts
@@ -218,7 +218,7 @@ class Parser {
}
// If binary / octal / hex
- const hex = /(0(?:x|o|b)[0-9a-f_]*)[^#]/gi.exec(dataString);
+ const hex = /^(0(?:x|o|b)[0-9a-f_]*)[^#]/gi.exec(dataString);
if (hex && hex[0]) {
return hex[0].trim();
}
diff --git a/std/encoding/toml_test.ts b/std/encoding/toml_test.ts
index cc3d190b0..565fe1eeb 100644
--- a/std/encoding/toml_test.ts
+++ b/std/encoding/toml_test.ts
@@ -29,6 +29,8 @@ Deno.test({
"whitespace\n is preserved.",
withApostrophe: "What if it's not?",
withSemicolon: `const message = 'hello world';`,
+ withHexNumberLiteral:
+ "Prevent bug from stripping string here ->0xabcdef",
},
};
const actual = parseFile(path.join(testFilesDir, "string.toml"));