diff --git a/__tests__/manager.tsx b/__tests__/manager.tsx index 92bae39..761cf8b 100644 --- a/__tests__/manager.tsx +++ b/__tests__/manager.tsx @@ -62,4 +62,30 @@ describe('Manager', () => { '', ); }); + + it('should keep og:* meta tags distinct by property (regression: property collapse)', () => { + const manager = new Manager(); + + manager.isServer = true; + + manager.pushTags( + <> + + + + + , + 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"'); + }); }); diff --git a/src/manager.ts b/src/manager.ts index c34e9f9..23dfa99 100644 --- a/src/manager.ts +++ b/src/manager.ts @@ -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}']`;