Skip to content

Commit bc4d6e8

Browse files
committed
Last fixes to download_urls.html logic for clientPathUrl
1 parent 2419820 commit bc4d6e8

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

idr_gallery/templates/idr_gallery/download_urls.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ <h1>Download URLs</h1>
128128
let urlPath = clientPath.split(idrId)[1];
129129
clientPathUrl = urlBase + idrId + urlPath;
130130
}
131+
if (clientPathUrl) {
132+
// client_path needs patching for /idr0045-reichmann-zygotespindle/
133+
clientPathUrl = clientPathUrl.replace("/idr0045-reichmann/", "/idr0045-reichmann-zygotespindle/");
134+
}
131135

132136
cells.forEach((cellText, colIndex) => {
133137
const td = document.createElement('td');
@@ -136,15 +140,18 @@ <h1>Download URLs</h1>
136140
// handle links or 'client_path' column...
137141
if (cellText.startsWith('http') || (headers[colIndex] === 'client_path' && clientPathUrl)) {
138142
const link = document.createElement('a');
139-
link.href = cellText.startsWith('http') ? cellText : clientPathUrl;
143+
// escape the URL to avoid issues with special characters in the client_path
144+
link.href = encodeURI(cellText.startsWith('http') ? cellText : clientPathUrl).replace("#", "%23");
145+
// fix idr0045 as above
146+
cellText = cellText.replace("/idr0045-reichmann/", "/idr0045-reichmann-zygotespindle/");
140147
link.textContent = cellText;
141148
link.target = '_blank';
142149
td.textContent = '';
143150
td.appendChild(link);
144151
} else if (colIndex == imageIdIndex) {
145152
// Add link to image viewer at /webclient/img_detail/1884807/
146153
const link = document.createElement('a');
147-
link.href = `/webclient/img_detail/${cellText}/?check_links=true`;
154+
link.href = encodeURI(`/webclient/img_detail/${cellText}/?check_links=true`).replace("#", "%23");
148155
link.textContent = cellText;
149156
link.target = '_blank';
150157
td.textContent = '';

0 commit comments

Comments
 (0)