refactor: Add internal method Utils.encodeForUrl for properly encoding email addresses for use in URLs (#9541)
This commit is contained in:
11
src/Utils.js
11
src/Utils.js
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user