0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 09:31:22 -05:00

fix: atob should throw dom exception (#5730)

This commit is contained in:
Ergenekon Yiğit 2020-05-23 04:52:50 +03:00 committed by GitHub
parent 526c9196e2
commit 4fa69e890e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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