Use the rendered share address here too

The link in the message under the picture now comes from share_link, which
returns the worker-rendered page rather than a guessed path on this site.
This commit is contained in:
gator 2026-09-09 02:21:45 +00:00
parent 6b7ef08fcc
commit f6f1335fff

View file

@ -1140,11 +1140,10 @@ function bindShare() {
// correct (video/mp4, filename=final.mp4) so anything that reads them is // correct (video/mp4, filename=final.mp4) so anything that reads them is
// fine, but clients that sniff the extension from the URL string are not. // fine, but clients that sniff the extension from the URL string are not.
// A filename query is accepted and ignored by the file service. // A filename query is accepted and ignored by the file service.
function named(url) { // Filled in by share_link, which owns the address. A link straight to the
// Through our own domain so an open can be counted; a link straight to the // file would be invisible to us; this one is counted server side.
// file is invisible to us. 33 characters against 74. var SHARE_LINK = "";
return location.origin + "/v/" + String(pid || "").slice(0, 8); function named(url) { return SHARE_LINK || ""; }
}
function paint(r) { function paint(r) {
var kb = Math.round((r.bytes || 0) / 1024); var kb = Math.round((r.bytes || 0) / 1024);
@ -1170,11 +1169,15 @@ function bindShare() {
+ '<span id="viewcount"></span></p>' + '<span id="viewcount"></span></p>'
+ '</div></div>'; + '</div></div>';
api("share_link", { email: email, project_id: pid }).then(function (s) { api("share_link", { email: email, project_id: pid }).then(function (s) {
if (!(s && s.ok)) return;
SHARE_LINK = s.url || "";
var el = document.getElementById("viewcount"); var el = document.getElementById("viewcount");
if (el && s && s.ok) { if (el) {
el.innerHTML = '<br>Opened ' + (s.views || 0) + ' time' el.innerHTML = '<br>' + esc(SHARE_LINK) + '<br>Opened ' + (s.views || 0)
+ ((s.views === 1) ? '' : 's') + '.'; + ' time' + ((s.views === 1) ? '' : 's') + '.';
} }
var t = document.getElementById("sharemsg");
if (t && SHARE_LINK) t.value = t.value.replace(/https?:\/\/\S+/, SHARE_LINK);
}); });
var sl = document.getElementById("sharelink"); var sl = document.getElementById("sharelink");
if (sl) sl.onclick = async function () { if (sl) sl.onclick = async function () {