如何在 JavaScript 中解码像这样编码的 URL

How to decode a URL encoded like this in JavaScript

我有一个具有此功能的脚本来对 URL 进行编码,但我不知道如何对其进行解码:

function app_base64_encode(e) {
  return btoa(
    encodeURIComponent(e).replace(/%([0-9A-F]{2})/g, function(e, n) {
      return String.fromCharCode("0x" + n);
    })
  );
}

function app_base64_decode(e) {
  //...
}

console.log(app_base64_encode(""))

好像atob就够了

function app_base64_encode(e) {
  return btoa(
    encodeURIComponent(e).replace(/%([0-9A-F]{2})/g, function(e, n) { // undo the encode for some reason
      return String.fromCharCode("0x" + n);
    })
  );
}

function app_base64_decode(e) {
  return atob(e)
}

const url = app_base64_encode("%0A%0D") 

//");

console.log(url)
console.log(app_base64_decode(url))