Skip to content

Commit 004b02b

Browse files
committed
feat: show generated hash and used algo
1 parent 621dd96 commit 004b02b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/index.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,9 @@ function getRelativeTimeString(date, lang = navigator.language) {
12061206
const data = await res.json();
12071207
const hash = data.hash_${{`process.env.HASH_ALGO`}}$;
12081208
if (hash === null || hash === undefined || String(hash).length === 0) throw new Error('unavailable');
1209-
await copyTextToClipboard(String(hash ?? ''));
1209+
const text = String(hash ?? '');
1210+
await copyTextToClipboard(text);
1211+
return text;
12101212
}
12111213
$[end]$
12121214

@@ -1541,7 +1543,7 @@ function getRelativeTimeString(date, lang = navigator.language) {
15411543
const note = document.createElement('span');
15421544
note.className = 'text-body-secondary';
15431545
note.textContent = `Too large to hash (>${HASH_MAX_FILE_SIZE_MB} MB)`;
1544-
entries.push({ label: 'Hash', value: note });
1546+
entries.push({ label: 'Hash (${{`process.env.HASH_ALGO`}}$)', value: note });
15451547
} else {
15461548
const link = document.createElement('a');
15471549
link.href = '#';
@@ -1552,13 +1554,13 @@ function getRelativeTimeString(date, lang = navigator.language) {
15521554
e.preventDefault();
15531555
if (!popupState.apiInfoUrl) return;
15541556
try {
1555-
await getHashViaApi(popupState.apiInfoUrl);
1556-
link.textContent = 'Hash copied to clipboard';
1557+
const hash = await getHashViaApi(popupState.apiInfoUrl);
1558+
link.textContent = `${hash} (copied to clipboard)`;
15571559
} catch (err) {
15581560
link.textContent = err && String(err.message) === 'too_large' ? 'Too large to hash' : 'Hash unavailable';
15591561
}
15601562
});
1561-
entries.push({ label: 'Hash', value: link });
1563+
entries.push({ label: 'Hash (${{`process.env.HASH_ALGO`}}$)', value: link });
15621564
}
15631565
}
15641566
$[end]$

0 commit comments

Comments
 (0)