Skip to content

Commit

Permalink
Merge pull request #1495 from nextstrain/feat/restrict-type
Browse files Browse the repository at this point in the history
[server] Restrict sidecar files
  • Loading branch information
jameshadfield committed Mar 27, 2022
2 parents ca59615 + aa5827c commit 2f872ba
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cli/server/getDatasetHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,18 @@ const interpretRequest = (req) => {
if (!query.prefix) throw new Error("'prefix' not defined in request");
const datanameParts = splitPrefixIntoParts(query.prefix);
const info = {parts: datanameParts};
if (query.type && query.type !== "tree") { // "tree" is deprecated
/* query.type is used to indicate which sidecar file should be fetched,
without it we fetch the "main" dataset JSON. See the `Dataset` constructor
in `./src/actions/loadData.js` for which sidecars auspice may try to fetch */
const sidecars = ['tip-frequencies', 'root-sequence', 'measurements'];
if (!query.type || query.type==="tree") {
// note that "tree" is deprecated and unnecessary, so it's ignored
info.dataType = "dataset";
} else if (sidecars.includes(query.type)) {
info.dataType = query.type;
} else {
info.dataType = "dataset";
throw new Error(`Unknown file type '${query.type}' requested.`);
}

return info;
};

Expand Down

0 comments on commit 2f872ba

Please sign in to comment.