Fix fallback

Fixes #1488

Signed-off-by: Richie Bendall <richiebendall@gmail.com>
This commit is contained in:
Richie Bendall 2021-07-17 00:40:03 +12:00
parent 94fa91d553
commit 57b7e83b90
No known key found for this signature in database
GPG key ID: 94AE1ACB662A2A6D
2 changed files with 10 additions and 5 deletions

View file

@ -7,8 +7,11 @@ const directoryName = dirname(fileURLToPath(import.meta.url))
const loadUser = async hostname => {
const [id] = hostname.split('.')
// Fallback
const user = {
copyright: '<copyright holders>' // Fallback
copyright: '<copyright holders>',
format: 'html',
license: 'MIT'
}
try {
@ -17,9 +20,11 @@ const loadUser = async hostname => {
...await loadJsonFile(path.join(directoryName, '..', 'users', `${id}.json`))
}
} catch (error) {
if (error.code !== 'ENOENT') {
throw error
if (error.code === 'ENOENT') {
return user
}
throw error
}
}

View file

@ -74,8 +74,8 @@ const getRoute = async (request, response) => {
const year = options.pinnedYear ?
options.pinnedYear :
removeFalsy([options.startYear, options.endYear]).join('-')
const license = (options.license || user.license || 'MIT').toUpperCase()
const format = options.format || user.format || 'html'
const license = (options.license || user.license).toUpperCase()
const format = options.format || user.format
const isPlainText = format !== 'html'
let name