summaryrefslogtreecommitdiff
path: root/std/encoding/base64url.ts
diff options
context:
space:
mode:
authorCasper Beyer <caspervonb@pm.me>2021-02-02 19:05:46 +0800
committerGitHub <noreply@github.com>2021-02-02 12:05:46 +0100
commit6abf126c2a7a451cded8c6b5e6ddf1b69c84055d (patch)
treefd94c013a19fcb38954844085821ec1601c20e18 /std/encoding/base64url.ts
parenta2b5d44f1aa9d64f448a2a3cc2001272e2f60b98 (diff)
chore: remove std directory (#9361)
This removes the std folder from the tree. Various parts of the tests are pretty tightly dependent on std (47 direct imports and 75 indirect imports, not counting the cli tests that use them as fixtures) so I've added std as a submodule for now.
Diffstat (limited to 'std/encoding/base64url.ts')
-rw-r--r--std/encoding/base64url.ts41
1 files changed, 0 insertions, 41 deletions
diff --git a/std/encoding/base64url.ts b/std/encoding/base64url.ts
deleted file mode 100644
index 45de1bd6d..000000000
--- a/std/encoding/base64url.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
-
-import * as base64 from "./base64.ts";
-
-/*
- * Some variants allow or require omitting the padding '=' signs:
- * https://en.wikipedia.org/wiki/Base64#URL_applications
- * @param base64url
- */
-export function addPaddingToBase64url(base64url: string): string {
- if (base64url.length % 4 === 2) return base64url + "==";
- if (base64url.length % 4 === 3) return base64url + "=";
- if (base64url.length % 4 === 1) {
- throw new TypeError("Illegal base64url string!");
- }
- return base64url;
-}
-
-function convertBase64urlToBase64(b64url: string): string {
- return addPaddingToBase64url(b64url).replace(/\-/g, "+").replace(/_/g, "/");
-}
-
-function convertBase64ToBase64url(b64: string): string {
- return b64.replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
-}
-
-/**
- * Encodes a given Uint8Array into a base64url representation
- * @param uint8
- */
-export function encode(uint8: Uint8Array): string {
- return convertBase64ToBase64url(base64.encode(uint8));
-}
-
-/**
- * Converts given base64url encoded data back to original
- * @param b64url
- */
-export function decode(b64url: string): Uint8Array {
- return base64.decode(convertBase64urlToBase64(b64url));
-}