mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-03 04:27:53 +00:00
feat: Add UI to manage web widget allowed domains (#12495)
## Summary - add allowed domains controls in the web widget configuration page. <img width="1064" height="699" alt="Screenshot 2025-09-23 at 8 52 21 PM" src="https://github.com/user-attachments/assets/8afd60b6-c81d-4f52-9cbe-07e70ad003d2" /> fixes: https://linear.app/chatwoot/issue/CW-5661/add-the-options-for-configure-allowed-domains-for-web-widget --------- Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com> Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Co-authored-by: iamsivin <iamsivin@gmail.com>
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
timeStampAppendedURL,
|
||||
getHostNameFromURL,
|
||||
extractFilenameFromUrl,
|
||||
sanitizeAllowedDomains,
|
||||
} from '../URLHelper';
|
||||
|
||||
describe('#URL Helpers', () => {
|
||||
@@ -318,4 +319,32 @@ describe('#URL Helpers', () => {
|
||||
).toBe('file.doc');
|
||||
});
|
||||
});
|
||||
|
||||
describe('sanitizeAllowedDomains', () => {
|
||||
it('returns empty string for falsy input', () => {
|
||||
expect(sanitizeAllowedDomains('')).toBe('');
|
||||
expect(sanitizeAllowedDomains(null)).toBe('');
|
||||
expect(sanitizeAllowedDomains(undefined)).toBe('');
|
||||
});
|
||||
|
||||
it('trims whitespace and converts newlines to commas', () => {
|
||||
const input = ' example.com \n foo.bar\nbar.baz ';
|
||||
expect(sanitizeAllowedDomains(input)).toBe('example.com,foo.bar,bar.baz');
|
||||
});
|
||||
|
||||
it('handles Windows newlines and mixed spacing', () => {
|
||||
const input = ' example.com\r\n\tfoo.bar , bar.baz ';
|
||||
expect(sanitizeAllowedDomains(input)).toBe('example.com,foo.bar,bar.baz');
|
||||
});
|
||||
|
||||
it('removes empty values from repeated commas', () => {
|
||||
const input = ',,example.com,,foo.bar,,';
|
||||
expect(sanitizeAllowedDomains(input)).toBe('example.com,foo.bar');
|
||||
});
|
||||
|
||||
it('lowercases entries and de-duplicates preserving order', () => {
|
||||
const input = 'Example.com,FOO.bar,example.com,Bar.Baz,foo.BAR';
|
||||
expect(sanitizeAllowedDomains(input)).toBe('example.com,foo.bar,bar.baz');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user