Skip to content

Commit

Permalink
Revert Zenodo API change
Browse files Browse the repository at this point in the history
  • Loading branch information
axelboc committed Nov 6, 2023
1 parent 03145be commit f8cf1fa
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/services/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { safeFetch } from '../fetch-utils';

interface ZenodoApiResponse {
files: {
filename: string;
links: { download: string }; // URL
key: string;
links: { self: string }; // URL
}[];
}

Expand Down Expand Up @@ -32,16 +32,16 @@ export async function fetchZenodoFileUrl(downloadUrl: string): Promise<string> {

const { files } = (await response.json()) as ZenodoApiResponse;

const file = files.find((f) => f.filename === filename);
const file = files.find((f) => f.key === filename);
if (!file) {
throw new Error('File not found in Zenodo record');
}

if (!file.links.download) {
if (!file.links.self) {
throw new Error(`File download URL not found in Zenodo record`);
}

return file.links.download;
return file.links.self;
}

export function validateRequiredUrl(fileUrl: string) {
Expand Down

0 comments on commit f8cf1fa

Please sign in to comment.