@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.js
CHANGED
|
@@ -1934,7 +1934,7 @@ import crypto from "crypto";
|
|
|
1934
1934
|
import fs2 from "fs";
|
|
1935
1935
|
import path2 from "path";
|
|
1936
1936
|
async function computeFileMd5Base64(file) {
|
|
1937
|
-
if (typeof window
|
|
1937
|
+
if (typeof window != "undefined") {
|
|
1938
1938
|
let buffer;
|
|
1939
1939
|
if (typeof file === "string") {
|
|
1940
1940
|
buffer = fs2.readFileSync(path2.resolve(file));
|
|
@@ -1945,7 +1945,11 @@ async function computeFileMd5Base64(file) {
|
|
|
1945
1945
|
} else {
|
|
1946
1946
|
const arrayBuffer = await file.arrayBuffer();
|
|
1947
1947
|
const SparkMD5 = (await import("spark-md5")).default;
|
|
1948
|
-
|
|
1948
|
+
const md5Hex = SparkMD5.ArrayBuffer.hash(arrayBuffer, false);
|
|
1949
|
+
const md5Bytes = new Uint8Array(md5Hex.match(/.{2}/g).map((b) => parseInt(b, 16)));
|
|
1950
|
+
let binary = "";
|
|
1951
|
+
md5Bytes.forEach((byte) => binary += String.fromCharCode(byte));
|
|
1952
|
+
return btoa(binary);
|
|
1949
1953
|
}
|
|
1950
1954
|
}
|
|
1951
1955
|
function parseFileNameAndSuffix(url) {
|