-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fixed a bug where spreading matchAll() result not working with b…
…uilt files (#1143) discussion: https://sendbird.slack.com/archives/G01290GCDCN/p1718676602610299
- Loading branch information
1 parent
61190e8
commit 5353f98
Showing
2 changed files
with
21 additions
and
1 deletion.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
src/modules/Message/utils/tokens/__tests__/asSafeUrl.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { asSafeURL } from '../asSafeURL'; | ||
|
||
describe('asSafeURL', () => { | ||
test('should return the same URL if it is already safe', () => { | ||
expect(asSafeURL('http://example.com')).toBe('http://example.com'); | ||
expect(asSafeURL('https://example.com')).toBe('https://example.com'); | ||
}); | ||
|
||
test('should return a safe URL if it is not safe', () => { | ||
expect(asSafeURL('mailto:[email protected]')).toBe('#'); | ||
// eslint-disable-next-line no-script-url | ||
expect(asSafeURL('javascript:alert(1)')).toBe('#'); | ||
expect(asSafeURL('javascript%3Aalert%281%29')).toBe('#'); | ||
expect(asSafeURL('data:text/html;base64,ABCDE==')).toBe('#'); | ||
}); | ||
|
||
test('should append a https:// protocol to the URL if it is missing', () => { | ||
expect(asSafeURL('example.com')).toBe('https://example.com'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters