Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix title attr #2

Merged
merged 3 commits into from
Jul 16, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export * from './types';
export default class IlcSdk {
private log: Console;
private defaultPublicPath: string;
private titleRegex = /<title\s*>.*<\/title\s*>/s;
private titleRegex = /<title.*>.*<\/title\s*>/s;
private publicPathProperyName: string;

/**
Expand Down
11 changes: 11 additions & 0 deletions test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,17 @@ describe('IlcSdk', () => {
);
});

it('should set page title formatted as HTML with attrs', () => {
const req = new MockReq(merge({}, defReq));
const res = new MockRes();

const pRes = ilcSdk.processRequest(req);
ilcSdk.processResponse(pRes, res, { pageTitle: '<title foo="bar">Test title</title>' });
expect(Buffer.from(res.getHeader('x-head-title') as string, 'base64').toString('utf8')).to.eq(
'<title foo="bar">Test title</title>',
);
});

it('should set page meta tags', () => {
const req = new MockReq(merge({}, defReq));
const res = new MockRes();
Expand Down