code: function urlEncode(data) {
    log("==================================================");
    log("Data before urlEncode");
    log("==================================================");
    log(data);
  
    if (data === "") {
      return data;
    }
  
    let find = ["~", "%20", "'"];
    let replace = ["%7E", "+", "%27"];
    let encodedData = encodeURIComponent(data);
  
    find.forEach((encodedChar, index) => {
      let regex = new RegExp(encodedChar, "g");
      encodedData = encodedData.replace(regex, replace[index]);
    });
  
    log("==================================================");
    log("Data after urlEncode");
    log("==================================================");
    log(encodedData);
  
    return encodedData;
  }
docs: 將資料編碼成與 .Net UrlEncode 相符的格式
  
  @param {string} data - 待編碼資料
  @private