diff --git a/packages/core/client/src/powered-by/index.tsx b/packages/core/client/src/powered-by/index.tsx index 949762aae..7dff2ef2a 100644 --- a/packages/core/client/src/powered-by/index.tsx +++ b/packages/core/client/src/powered-by/index.tsx @@ -33,7 +33,7 @@ export const PoweredBy = () => { dangerouslySetInnerHTML={{ __html: parseHTML( customBrandPlugin?.options?.options?.brand || - `Powered by NocoBase`, + `Powered by NocoBase`, { appVersion }, ), }} diff --git a/packages/core/utils/src/__tests__/parseHTML.test.ts b/packages/core/utils/src/__tests__/parseHTML.test.ts new file mode 100644 index 000000000..4a553296c --- /dev/null +++ b/packages/core/utils/src/__tests__/parseHTML.test.ts @@ -0,0 +1,41 @@ +import { parseHTML } from '../parseHTML'; + +describe('parseHTML', () => { + it('should replace variables in HTML with their corresponding values', () => { + const html = '
{{content}}
'; + const variables = { + title: 'Hello', + content: 'World', + }; + const expected = 'World
'; + + const result = parseHTML(html, variables); + + expect(result).toEqual(expected); + }); + + it('should not replace variables that are not present in the variables object', () => { + const html = '{{content}}
'; + const variables = { + title: 'Hello', + }; + const expected = '{{content}}
'; + + const result = parseHTML(html, variables); + + expect(result).toEqual(expected); + }); + + it('should not replace variables that have undefined values', () => { + const html = '{{content}}
'; + const variables = { + title: 'Hello', + content: undefined, + }; + const expected = '{{content}}
'; + + const result = parseHTML(html, variables); + + expect(result).toEqual(expected); + }); +});