Skip to content

Commit

Permalink
Use baseUrl as uploadAppPath if it's not explicitly set. #129
Browse files Browse the repository at this point in the history
  • Loading branch information
psi-4ward committed Dec 4, 2020
1 parent 152b324 commit 5647f04
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
5 changes: 5 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ for (let k in config) {
if(!config.baseUrl.endsWith('/')) config.baseUrl = config.baseUrl + '/';
if(!config.uploadAppPath.endsWith('/')) config.uploadAppPath = config.uploadAppPath + '/';

// Use baseUrl as uploadAppPath if it's not explicitly set
if(config.uploadAppPath === '/' && config.baseUrl !== '/') {
config.uploadAppPath = config.baseUrl;
}

// Load language files
config.languages = {
[config.defaultLanguage]: require(`./lang/${config.defaultLanguage}`) // default language
Expand Down
22 changes: 9 additions & 13 deletions lib/endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,12 @@ config.plugins.forEach(pluginName => {
});

// Upload App
app.get(`${ config.baseUrl }`, (req, res) => {
if (config.uploadAppPath !== `${ config.baseUrl }`) {
res.status(304).redirect(config.uploadAppPath);
} else {
res.send(uploadPage({
...pugVars,
baseUrl: config.uploadAppPath || config.baseUrl,
lang: req.translations
}));
}
});

app.get(config.uploadAppPath, (req, res) => {
res.send(uploadPage({...pugVars, lang: req.translations}));
res.send(uploadPage({
...pugVars,
baseUrl: config.uploadAppPath,
lang: req.translations
}));
});

// Return translations
Expand Down Expand Up @@ -378,6 +370,10 @@ app.use(`${ config.baseUrl }files`,
);

app.use((req, res, next) => {
if(req.url === '/') {
return res.redirect(config.uploadAppPath);
}

res.status(404).send(errorPage({
...pugVars,
error: 'Download bucket not found.',
Expand Down

0 comments on commit 5647f04

Please sign in to comment.