Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions __tests__/manager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,30 @@ describe('Manager', () => {
'<meta charset="UTF-8"><meta data-test="2" style="color: black;"><style>#test { color: red; }</style>',
);
});

it('should keep og:* meta tags distinct by property (regression: property collapse)', () => {
const manager = new Manager();

manager.isServer = true;

manager.pushTags(
<>
<meta property="og:title" content="Title A" />
<meta property="og:description" content="Desc B" />
<meta property="og:url" content="https://example.com/page" />
<meta property="og:image" content="https://example.com/img.png" />
</>,
containerId,
);

const { meta } = manager.getTags();
const htmlMeta = renderServerMeta(meta);
const ogCount = (htmlMeta.match(/property="og:/g) ?? []).length;

expect(ogCount).to.equal(4);
expect(htmlMeta).to.contain('property="og:title"');
expect(htmlMeta).to.contain('property="og:description"');
expect(htmlMeta).to.contain('property="og:url"');
expect(htmlMeta).to.contain('property="og:image"');
});
});
2 changes: 1 addition & 1 deletion src/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class Manager {
let key = '';

// try to build unique key by unique props
for (const uniqueAttr of ['id', 'name', 'href', 'src']) {
for (const uniqueAttr of ['id', 'name', 'property', 'href', 'src']) {
if (props[uniqueAttr]) {
key = `[${uniqueAttr}='${props[uniqueAttr] as string}']`;

Expand Down
Loading