瀏覽代碼

'Show Base64 offsets' operation show supports base64 input. Closes #276

n1474335 6 年之前
父節點
當前提交
61f2f2d2e3
共有 2 個文件被更改,包括 11 次插入1 次删除
  1. 1 0
      src/core/lib/Base64.mjs
  2. 10 1
      src/core/operations/ShowBase64Offsets.mjs

+ 1 - 0
src/core/lib/Base64.mjs

@@ -81,6 +81,7 @@ export function fromBase64(data, alphabet="A-Za-z0-9+/=", returnType="string", r
         return returnType === "string" ? "" : [];
     }
 
+    alphabet = alphabet || "A-Za-z0-9+/=";
     alphabet = Utils.expandAlphRange(alphabet).join("");
 
     const output = [];

+ 10 - 1
src/core/operations/ShowBase64Offsets.mjs

@@ -36,6 +36,11 @@ class ShowBase64Offsets extends Operation {
                 name: "Show variable chars and padding",
                 type: "boolean",
                 value: true
+            },
+            {
+                name: "Input format",
+                type: "option",
+                value: ["Raw", "Base64"]
             }
         ];
     }
@@ -46,7 +51,11 @@ class ShowBase64Offsets extends Operation {
      * @returns {html}
      */
     run(input, args) {
-        const [alphabet, showVariable] = args;
+        const [alphabet, showVariable, format] = args;
+
+        if (format === "Base64") {
+            input = fromBase64(Utils.byteArrayToUtf8(input), null, "byteArray");
+        }
 
         let offset0 = toBase64(input, alphabet),
             offset1 = toBase64([0].concat(input), alphabet),