feat: Add custom domain to article URL if custom domain exists for the portal (#11349)
Portals can have custom domains. When inserting or previewing articles, we consider the frontend URL. This PR fixes article URL generation to properly include the portal's custom domain.
This commit is contained in:
@@ -25,5 +25,47 @@ describe('PortalHelper', () => {
|
||||
).toEqual('https://help.chatwoot.com/hc/handbook/articles/article-slug');
|
||||
window.chatwootConfig = {};
|
||||
});
|
||||
|
||||
it('returns the correct url with custom domain', () => {
|
||||
window.chatwootConfig = {
|
||||
hostURL: 'https://app.chatwoot.com',
|
||||
helpCenterURL: 'https://help.chatwoot.com',
|
||||
};
|
||||
expect(
|
||||
buildPortalArticleURL(
|
||||
'handbook',
|
||||
'culture',
|
||||
'fr',
|
||||
'article-slug',
|
||||
'custom-domain.dev'
|
||||
)
|
||||
).toEqual('https://custom-domain.dev/handbook/articles/article-slug');
|
||||
});
|
||||
|
||||
it('handles https in custom domain correctly', () => {
|
||||
window.chatwootConfig = {
|
||||
hostURL: 'https://app.chatwoot.com',
|
||||
helpCenterURL: 'https://help.chatwoot.com',
|
||||
};
|
||||
expect(
|
||||
buildPortalArticleURL(
|
||||
'handbook',
|
||||
'culture',
|
||||
'fr',
|
||||
'article-slug',
|
||||
'https://custom-domain.dev'
|
||||
)
|
||||
).toEqual('https://custom-domain.dev/handbook/articles/article-slug');
|
||||
});
|
||||
|
||||
it('uses hostURL when helpCenterURL is not available', () => {
|
||||
window.chatwootConfig = {
|
||||
hostURL: 'https://app.chatwoot.com',
|
||||
helpCenterURL: '',
|
||||
};
|
||||
expect(
|
||||
buildPortalArticleURL('handbook', 'culture', 'fr', 'article-slug')
|
||||
).toEqual('https://app.chatwoot.com/hc/handbook/articles/article-slug');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user