File tree Expand file tree Collapse file tree 3 files changed +30
-3
lines changed Expand file tree Collapse file tree 3 files changed +30
-3
lines changed Original file line number Diff line number Diff line change 361361
362362PLATFORMS
363363 arm64-darwin-22
364+ arm64-darwin-23
364365 x86_64-darwin-19
365366 x86_64-darwin-20
366367 x86_64-darwin-21
Original file line number Diff line number Diff line change @@ -84,13 +84,27 @@ def gis_access_link(metadata)
8484 # At this point, we don't show download links for non-MIT records. For MIT records, the download link is stored
8585 # consistently as a download link. We are confirming that the link text is 'Data' for added confirmation.
8686 if access_type ( metadata ) == 'unknown: check with owning institution'
87- links . select { | link | link [ 'kind' ] == 'Website' } . first [ 'url' ]
87+ website_url ( links )
8888 else
89- url = links . select { | link | link [ 'kind' ] == 'Download' && link [ 'text' ] == 'Data' } . first [ 'url' ]
90- " #{ url } ?timdexui=true"
89+ url = download_url ( links )
90+ append_timdexui ( url )
9191 end
9292 end
9393
94+ def website_url ( links )
95+ links . select { |link | link [ 'kind' ] == 'Website' } . first [ 'url' ]
96+ end
97+
98+ def download_url ( links )
99+ links . select { |link | link [ 'kind' ] == 'Download' && link [ 'text' ] == 'Data' } . first [ 'url' ]
100+ end
101+
102+ def append_timdexui ( url )
103+ uri = Addressable ::URI . parse ( url )
104+ uri . query_values = ( uri . query_values || { } ) . merge ( timdexui : true )
105+ uri . to_s
106+ end
107+
94108 def access_type ( metadata )
95109 access_right = metadata [ 'rights' ] &.select { |right | right [ 'kind' ] == 'Access to files' }
96110 return if access_right . blank?
Original file line number Diff line number Diff line change @@ -247,6 +247,18 @@ class RecordHelperTest < ActionView::TestCase
247247 assert_equal 'https://example.org/dz_f7regions_2016.zip?timdexui=true' , gis_access_link ( access_auth )
248248 end
249249
250+ test 'append_timdexui_with_no_existing_query_values' do
251+ url = 'https://example.org/dz_f7regions_2016.zip'
252+ assert_equal ( 'https://example.org/dz_f7regions_2016.zip?timdexui=true' ,
253+ append_timdexui ( url ) )
254+ end
255+
256+ test 'append_timdexui_with_existing_query_values' do
257+ url = 'https://example.org/dz_f7regions_2016.zip?hallo=goodbye'
258+ assert_equal ( 'https://example.org/dz_f7regions_2016.zip?hallo=goodbye&timdexui=true' ,
259+ append_timdexui ( url ) )
260+ end
261+
250262 test 'source_metadata_available? returns true if source metadata link exists' do
251263 links = [ { 'kind' => 'Download' , 'text' => 'Source Metadata' , 'url' => 'https://example.org/metadata.zip' } ]
252264 assert source_metadata_available? ( links )
You can’t perform that action at this time.
0 commit comments