fix: don't replace # in web link fragments for attachment links

This commit is contained in:
Gursheen Anand 2026-02-26 16:28:39 +05:30
parent 890098cbd7
commit c4442a3a5d

View file

@ -180,8 +180,18 @@ frappe.ui.form.Attachments = class Attachments {
file_url = "/files/" + attachment.file_name;
}
}
const is_web_url = /^(https?:)?\/\//i.test(file_url);
file_url = encodeURI(file_url);
// hash is not escaped, https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI
return encodeURI(file_url).replace(/#/g, "%23");
// only encode hash if it's a local file path, not a web URL
if (!is_web_url) {
file_url = file_url.replace(/#/g, "%23");
}
return file_url;
}
get_file_id_from_file_url(file_url) {
var fid;