diff --git a/lib/load-user.js b/lib/load-user.js index acb3fc7b..d7b3d491 100644 --- a/lib/load-user.js +++ b/lib/load-user.js @@ -7,8 +7,11 @@ const directoryName = dirname(fileURLToPath(import.meta.url)) const loadUser = async hostname => { const [id] = hostname.split('.') + // Fallback const user = { - copyright: '' // Fallback + copyright: '', + 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 } } diff --git a/routes/get.js b/routes/get.js index 70faac79..c7dfaaa3 100644 --- a/routes/get.js +++ b/routes/get.js @@ -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