Skip to content
This repository has been archived by the owner on Nov 30, 2020. It is now read-only.

Commit

Permalink
fix: atob should throw dom exception (denoland#5730)
Browse files Browse the repository at this point in the history
  • Loading branch information
ergenekonyigit committed May 23, 2020
1 parent 526c919 commit 4fa69e8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cli/js/web/text_encoding.ts
Expand Up @@ -23,6 +23,7 @@
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.

import { DOMExceptionImpl as DOMException } from "./dom_exception.ts";
import * as base64 from "./base64.ts";
import { decodeUtf8 } from "./decode_utf8.ts";
import { core } from "../core.ts";
Expand Down Expand Up @@ -101,8 +102,10 @@ export function atob(s: string): string {

const rem = s.length % 4;
if (rem === 1 || /[^+/0-9A-Za-z]/.test(s)) {
// TODO: throw `DOMException`
throw new TypeError("The string to be decoded is not correctly encoded");
throw new DOMException(
"The string to be decoded is not correctly encoded",
"DataDecodeError"
);
}

// base64-js requires length exactly times of 4
Expand Down

0 comments on commit 4fa69e8

Please sign in to comment.