refactor: Add internal method Utils.encodeForUrl for properly encoding email addresses for use in URLs (#9541)

This commit is contained in:
Daniel
2025-03-06 11:57:37 +11:00
committed by GitHub
parent 22e8568936
commit 533a60e218
3 changed files with 22 additions and 1 deletions

View File

@@ -1,6 +1,17 @@
const Utils = require('../src/Utils');
describe('Utils', () => {
describe('encodeForUrl', () => {
it('should properly escape email with all special ASCII characters for use in URLs', async () => {
const values = [
{ input: `!\"'),.:;<>?]^}`, output: '%21%22%27%29%2C%2E%3A%3B%3C%3E%3F%5D%5E%7D' },
]
for (const value of values) {
expect(Utils.encodeForUrl(value.input)).toBe(value.output);
}
});
});
describe('addNestedKeysToRoot', () => {
it('should move the nested keys to root of object', async () => {
const obj = {