Skip to content

Commit 4833cc2

Browse files
authored
fix STAC API navigation links (#1170)
1 parent 07a19e4 commit 4833cc2

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

pycsw/stac/api.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -463,9 +463,15 @@ def items(self, headers_, json_post_data, args, collection='metadata:main'):
463463
LOGGER.debug('Missing link relation; adding rel=related')
464464
link['rel'] = 'related'
465465

466-
for count, value in enumerate(response2['links']):
467-
if value['rel'] == 'alternate':
468-
response2['links'].pop(count)
466+
links2 = []
467+
468+
for link in response2['links']:
469+
if link['rel'] in ['alternate', 'collection']:
470+
continue
471+
link['href'] = link['href'].replace('collections/metadata:main/items', 'search')
472+
links2.append(link)
473+
474+
response2['links'] = links2
469475

470476
response2['links'].extend([{
471477
'rel': 'root',

tests/functionaltests/suites/stac_api/test_stac_api_functional.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,11 @@ def test_items(config):
167167
assert 'href' in link
168168
assert 'rel' in link
169169

170+
for link in content['links']:
171+
assert 'href' in link
172+
assert 'rel' in link
173+
assert 'metadata:main' not in link['href']
174+
170175
# test GET KVP requests
171176
content = json.loads(api.items({}, None, {'bbox': '-180,-90,180,90'})[2])
172177
assert len(content['features']) == 10

0 commit comments

Comments
 (0)