Skip to content

Commit 39ac3be

Browse files
committed
fix(getValue): bug
1 parent 4cd09ec commit 39ac3be

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ export function stringify(object) {
2020
}
2121

2222
export function getValue(string) {
23-
return string.match(/(["'`])(?<value>.*?)\1/)?.groups?.value;
23+
return string?.match?.(/(["'`])(?<value>.*?)\1/)?.groups?.value ?? string;
2424
}

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "markdown-code-block-meta",
3-
"version": "0.0.0",
3+
"version": "0.0.2",
44
"description": "A library to parse/stringify metadata of markdown code block",
55
"license": "MIT",
66
"author": {

test.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ test('getValue', (t) => {
4040
t.is('123', getValue('`123`'));
4141
t.is('123', getValue("'123'"));
4242
t.is('123', getValue("'123'"));
43+
t.is('123"', getValue('123"'));
4344
});

0 commit comments

Comments
 (0)