fix(mdx): robust parsing for payload data and ignore sentry pipe noise
This commit is contained in:
17
tests/mdx-regex.test.ts
Normal file
17
tests/mdx-regex.test.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { fixMdxDataProps } from '../lib/mdx-utils';
|
||||
|
||||
describe('MDX Data Props Fixer', () => {
|
||||
it('should correctly parse MDX with nested JSON containing }}', () => {
|
||||
// This string simulates the exact structure that causes the bug in n2x2y.mdx
|
||||
const mdxInput = `<Block type="productTabs" data={{"content":{"root":{"children":[]}},"id":"123"}} />`;
|
||||
|
||||
const result = fixMdxDataProps(mdxInput);
|
||||
|
||||
// The expected output should have the entire JSON object enclosed in data="{...}"
|
||||
// and NO trailing characters left over from the regex truncating early.
|
||||
const expected = `<Block type="productTabs" data="{"content":{"root":{"children":[]}},"id":"123"}" />`;
|
||||
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user