@@ -94,19 +94,35 @@ <h1>Download URLs</h1>
9494 headerRow . appendChild ( th ) ;
9595 } ) ;
9696
97- // Create table body
97+ let clientPathIndex = headers . indexOf ( 'client_path' ) ;
98+ let downloadUrlIndex = headers . indexOf ( 'download_url' ) ;
99+ let idrIdIndex = headers . indexOf ( 'idrid' ) ;
100+
101+ // Create table body - update client_path to URL, based on the download_url column...
98102 const tbody = table . createTBody ( ) ;
99103 lines . slice ( 1 ) . forEach ( line => {
100104 if ( line . trim ( ) === '' ) return ; // Skip empty lines
101105 const row = tbody . insertRow ( ) ;
102106 const cells = line . split ( '\t' ) ;
103- cells . forEach ( cellText => {
107+
108+ let idrId = cells [ idrIdIndex ] ;
109+ let clientPath = cells [ clientPathIndex ] ;
110+ let downloadUrl = cells [ downloadUrlIndex ] ;
111+ let clientPathUrl ;
112+ // e.g. https://ftp.ebi.ac.uk/pub/databases/IDR/idr0001-graml-sysgro
113+ if ( downloadUrl . includes ( idrId ) && clientPath . includes ( idrId ) ) {
114+ let urlBase = downloadUrl . split ( idrId ) [ 0 ] ;
115+ let urlPath = clientPath . split ( idrId ) [ 1 ] ;
116+ clientPathUrl = urlBase + idrId + urlPath ;
117+ }
118+
119+ cells . forEach ( ( cellText , colIndex ) => {
104120 const td = document . createElement ( 'td' ) ;
105121 td . style . border = '1px solid #ddd' ;
106122 td . style . padding = '2px' ;
107- if ( cellText . startsWith ( 'http' ) ) {
123+ if ( cellText . startsWith ( 'http' ) || ( headers [ colIndex ] === 'client_path' && clientPathUrl ) ) {
108124 const link = document . createElement ( 'a' ) ;
109- link . href = cellText ;
125+ link . href = cellText . startsWith ( 'http' ) ? cellText : clientPathUrl ;
110126 link . textContent = cellText ;
111127 link . target = '_blank' ;
112128 td . textContent = '' ;
0 commit comments