Browse Source

Bugfix/HTML template of personal finance tools with dot in key (#8371)

Fix HTML template of personal finance tools with dot in key
pull/8374/head^2
Thomas Kaul 2 weeks ago
committed by GitHub
parent
commit
d8995473c1
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 17
      apps/api/src/middlewares/html-template.middleware.spec.ts
  2. 7
      apps/api/src/middlewares/html-template.middleware.ts

17
apps/api/src/middlewares/html-template.middleware.spec.ts

@ -1,4 +1,5 @@
import { I18nService } from '@ghostfolio/api/services/i18n/i18n.service';
import { personalFinanceTools } from '@ghostfolio/common/personal-finance-tools';
import { Logger } from '@nestjs/common';
import { NextFunction, Request, Response } from 'express';
@ -110,6 +111,22 @@ describe('HtmlTemplateMiddleware', () => {
).toContain('content="Compare 8FIGURES"');
});
it.each(
personalFinanceTools.filter(({ alias, key }) => {
return (alias ?? key).includes('.');
})
)(
'serves the template of a personal finance tool with a dot in the key ($key)',
({ alias, key, name }) => {
expect(
getResponseBody({
locale: createLocale({ productDescription: 'Compare ${name}' }),
originalUrl: `/en/resources/personal-finance-tools/open-source-alternative-to-${alias ?? key}`
})
).toContain(`content="Compare ${name}"`);
}
);
it('falls back to the generic description if the name token is not in the description of a personal finance tool', () => {
expect(
getResponseBody({

7
apps/api/src/middlewares/html-template.middleware.ts

@ -364,9 +364,10 @@ export class HtmlTemplateMiddleware implements NestMiddleware {
if (filename === '/assets/LICENSE') {
return true;
} else if (
filename.endsWith('-de.fi') ||
filename.endsWith('-markets.sh') ||
filename.includes('auth/ey')
filename.includes('auth/ey') ||
personalFinanceTools.some(({ alias, key }) => {
return filename.endsWith(`-${alias ?? key}`);
})
) {
return false;
}

Loading…
Cancel
Save