mirror of
https://github.com/samsonjs/mit-license.git
synced 2026-03-25 09:25:49 +00:00
Fix fallback
Fixes #1488 Signed-off-by: Richie Bendall <richiebendall@gmail.com>
This commit is contained in:
parent
94fa91d553
commit
57b7e83b90
2 changed files with 10 additions and 5 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue