Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMR-10242: Fix /items/ path for collections which have granule metadata #372

Merged
merged 3 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/routes/__tests__/browse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe("addItemLinkIfPresent", () => {

const numberoOfLinks = stacCollection.links.length;
// Invoke method
addItemLinkIfPresent(stacCollection, "https://foo.com/items");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were talking about this on slack and I'm not sure I understand. Is it the case that this part of the url 'items' is going to be in the actual metadata and thus if we append it going to cause a problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the case of CMR collections with granules, the metadata will not contain a URL for the items endpoint, it is inferred and generated in code. CMR collections without granules and a STAC related url will have their link pulled from metadata.

addItemLinkIfPresent(stacCollection, "https://foo.com");
// Observe an addiitonal link in the STAC Collection with rel=items etc.
expect(stacCollection.links.length).to.equal(numberoOfLinks + 1);
expect(stacCollection).to.have.deep.property("links", [
Expand Down
3 changes: 1 addition & 2 deletions src/routes/browse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ export const collectionsHandler = async (req: Request, res: Response): Promise<v
href: encodeURI(stacRoot),
type: "application/json",
});

addItemLinkIfPresent(collection, `${getBaseUrl(self)}/${encodeURIComponent(collection.id)}`);
});

Expand Down Expand Up @@ -125,7 +124,7 @@ export function addItemLinkIfPresent(collection: STACCollection, url: string) {
if (!itemsLink) {
collection.links.push({
rel: "items",
href: url,
href: `${url}/items`,
type: "application/geo+json",
title: "Collection Items",
});
Expand Down