diff --git a/pycsw/stac/api.py b/pycsw/stac/api.py index fb22bb94c..3cdbc22f1 100644 --- a/pycsw/stac/api.py +++ b/pycsw/stac/api.py @@ -463,9 +463,15 @@ def items(self, headers_, json_post_data, args, collection='metadata:main'): LOGGER.debug('Missing link relation; adding rel=related') link['rel'] = 'related' - for count, value in enumerate(response2['links']): - if value['rel'] == 'alternate': - response2['links'].pop(count) + links2 = [] + + for link in response2['links']: + if link['rel'] in ['alternate', 'collection']: + continue + link['href'] = link['href'].replace('collections/metadata:main/items', 'search') + links2.append(link) + + response2['links'] = links2 response2['links'].extend([{ 'rel': 'root', diff --git a/tests/functionaltests/suites/stac_api/test_stac_api_functional.py b/tests/functionaltests/suites/stac_api/test_stac_api_functional.py index b59e5c81f..ea405dce4 100644 --- a/tests/functionaltests/suites/stac_api/test_stac_api_functional.py +++ b/tests/functionaltests/suites/stac_api/test_stac_api_functional.py @@ -167,6 +167,11 @@ def test_items(config): assert 'href' in link assert 'rel' in link + for link in content['links']: + assert 'href' in link + assert 'rel' in link + assert 'metadata:main' not in link['href'] + # test GET KVP requests content = json.loads(api.items({}, None, {'bbox': '-180,-90,180,90'})[2]) assert len(content['features']) == 10