File tree 3 files changed +30
-3
lines changed
3 files changed +30
-3
lines changed Original file line number Diff line number Diff line change 361
361
362
362
PLATFORMS
363
363
arm64-darwin-22
364
+ arm64-darwin-23
364
365
x86_64-darwin-19
365
366
x86_64-darwin-20
366
367
x86_64-darwin-21
Original file line number Diff line number Diff line change @@ -84,13 +84,27 @@ def gis_access_link(metadata)
84
84
# At this point, we don't show download links for non-MIT records. For MIT records, the download link is stored
85
85
# consistently as a download link. We are confirming that the link text is 'Data' for added confirmation.
86
86
if access_type ( metadata ) == 'unknown: check with owning institution'
87
- links . select { | link | link [ 'kind' ] == 'Website' } . first [ 'url' ]
87
+ website_url ( links )
88
88
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 )
91
91
end
92
92
end
93
93
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
+
94
108
def access_type ( metadata )
95
109
access_right = metadata [ 'rights' ] &.select { |right | right [ 'kind' ] == 'Access to files' }
96
110
return if access_right . blank?
Original file line number Diff line number Diff line change @@ -247,6 +247,18 @@ class RecordHelperTest < ActionView::TestCase
247
247
assert_equal 'https://example.org/dz_f7regions_2016.zip?timdexui=true' , gis_access_link ( access_auth )
248
248
end
249
249
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
+
250
262
test 'source_metadata_available? returns true if source metadata link exists' do
251
263
links = [ { 'kind' => 'Download' , 'text' => 'Source Metadata' , 'url' => 'https://example.org/metadata.zip' } ]
252
264
assert source_metadata_available? ( links )
You can’t perform that action at this time.
0 commit comments