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

@@ -399,6 +399,17 @@ class Utils {
}
return obj;
}
/**
* Encodes a string to be used in a URL.
* @param {String} input The string to encode.
* @returns {String} The encoded string.
*/
static encodeForUrl(input) {
return encodeURIComponent(input).replace(/[!'.()*]/g, char =>
'%' + char.charCodeAt(0).toString(16).toUpperCase()
);
}
}
module.exports = Utils;