diff options
author | Ergenekon Yiğit <yigitergenekon@gmail.com> | 2020-05-23 04:52:50 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-22 21:52:50 -0400 |
commit | 4fa69e890ee92c3b81beed8c8a2b262db8c905ac (patch) | |
tree | 5fef5310ff44f70d64302b56e3ee94968dc15c97 /cli/js | |
parent | 526c9196e23af34d1ecd424d09c99c7003c33844 (diff) |
fix: atob should throw dom exception (#5730)
Diffstat (limited to 'cli/js')
-rw-r--r-- | cli/js/web/text_encoding.ts | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/cli/js/web/text_encoding.ts b/cli/js/web/text_encoding.ts index 9f9b4e220..cd93d7a89 100644 --- a/cli/js/web/text_encoding.ts +++ b/cli/js/web/text_encoding.ts @@ -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"; @@ -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 |