Skip to content

Commit

Permalink
charon: Rename variable containing the corrected/resolved prefix
Browse files Browse the repository at this point in the history
auspiceDisplayUrl → resolvedPrefix because the value is a "prefix",
just like the one which got passed into parsePrefix(), not a full
URL, and it's a resolved version of the partial prefix passed in.
  • Loading branch information
tsibley committed Apr 8, 2021
1 parent edd8548 commit 3278918
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/getDataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,15 @@ const getDataset = async (req, res) => {
return res.status(400).send(`Couldn't parse the url "${query.prefix}"`);
}

const {source, dataset, auspiceDisplayUrl} = datasetInfo;
const {source, dataset, resolvedPrefix} = datasetInfo;

// Authorization
if (!source.visibleToUser(req.user)) {
return helpers.unauthorized(req, res);
}

const baseUrl = req.url.split(query.prefix)[0];
let redirectUrl = baseUrl + '/' + auspiceDisplayUrl;
let redirectUrl = baseUrl + '/' + resolvedPrefix;
if (query.type) {
redirectUrl += `&type=${query.type}`;
}
Expand Down
9 changes: 5 additions & 4 deletions src/getDatasetHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const correctPrefixFromAvailable = (sourceName, prefixParts) => {


/* Parse the prefix (a path-like string specifying a source + dataset path)
* with canonicalization. Prefixes are case-sensitive.
* with resolving of partial prefixes. Prefixes are case-sensitive.
*/
const parsePrefix = (prefix) => {
let {source, prefixParts} = splitPrefixIntoParts(prefix);
Expand All @@ -163,12 +163,13 @@ const parsePrefix = (prefix) => {
// Source classes.
prefixParts = correctPrefixFromAvailable(source.name, prefixParts);

// The URL to be displayed in Auspice
const auspiceDisplayUrl = joinPartsIntoPrefix({source, prefixParts});
// The resolved prefix, possibly "corrected" above, which we want to use for
// display.
const resolvedPrefix = joinPartsIntoPrefix({source, prefixParts});

const dataset = source.dataset(prefixParts);

return ({auspiceDisplayUrl, source, dataset});
return ({source, dataset, resolvedPrefix});

};

Expand Down

0 comments on commit 3278918

Please sign in to comment.