uppercase constant

This commit is contained in:
TheSavageTeddy 2022-11-27 14:25:18 +08:00
parent afb9fd8408
commit c19fe5cffa
1 changed files with 2 additions and 2 deletions

View File

@ -65,10 +65,10 @@ class URLEncode extends Operation {
* @returns {string} * @returns {string}
*/ */
encodeAllSpecialChars (str) { encodeAllSpecialChars (str) {
const specialChars = "!#'()*-._~"; const SPECIAL_CHARS = "!#'()*-._~";
let encoded = ""; let encoded = "";
for (const char of str) { for (const char of str) {
if (encodeURIComponent(char) === char && specialChars.includes(char)) { if (encodeURIComponent(char) === char && SPECIAL_CHARS.includes(char)) {
encoded += "%" + this.frontPad(char.charCodeAt(0).toString(16).toUpperCase(), 2, "0"); encoded += "%" + this.frontPad(char.charCodeAt(0).toString(16).toUpperCase(), 2, "0");
} else { } else {
encoded += encodeURIComponent(char); encoded += encodeURIComponent(char);