@ctil/gql 1.0.15 → 1.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +6 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4703,7 +4703,7 @@ var import_crypto = __toESM(require("crypto"), 1);
|
|
|
4703
4703
|
var import_fs2 = __toESM(require("fs"), 1);
|
|
4704
4704
|
var import_path2 = __toESM(require("path"), 1);
|
|
4705
4705
|
async function computeFileMd5Base64(file) {
|
|
4706
|
-
if (typeof window
|
|
4706
|
+
if (typeof window != "undefined") {
|
|
4707
4707
|
let buffer;
|
|
4708
4708
|
if (typeof file === "string") {
|
|
4709
4709
|
buffer = import_fs2.default.readFileSync(import_path2.default.resolve(file));
|
|
@@ -4714,7 +4714,11 @@ async function computeFileMd5Base64(file) {
|
|
|
4714
4714
|
} else {
|
|
4715
4715
|
const arrayBuffer = await file.arrayBuffer();
|
|
4716
4716
|
const SparkMD5 = (await import("spark-md5")).default;
|
|
4717
|
-
|
|
4717
|
+
const md5Hex = SparkMD5.ArrayBuffer.hash(arrayBuffer, false);
|
|
4718
|
+
const md5Bytes = new Uint8Array(md5Hex.match(/.{2}/g).map((b) => parseInt(b, 16)));
|
|
4719
|
+
let binary = "";
|
|
4720
|
+
md5Bytes.forEach((byte) => binary += String.fromCharCode(byte));
|
|
4721
|
+
return btoa(binary);
|
|
4718
4722
|
}
|
|
4719
4723
|
}
|
|
4720
4724
|
function parseFileNameAndSuffix(url) {
|