mirror of
https://github.com/samsonjs/mit-license.git
synced 2026-04-27 15:07:42 +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 loadUser = async hostname => {
|
||||||
const [id] = hostname.split('.')
|
const [id] = hostname.split('.')
|
||||||
|
|
||||||
|
// Fallback
|
||||||
const user = {
|
const user = {
|
||||||
copyright: '<copyright holders>' // Fallback
|
copyright: '<copyright holders>',
|
||||||
|
format: 'html',
|
||||||
|
license: 'MIT'
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
@ -17,9 +20,11 @@ const loadUser = async hostname => {
|
||||||
...await loadJsonFile(path.join(directoryName, '..', 'users', `${id}.json`))
|
...await loadJsonFile(path.join(directoryName, '..', 'users', `${id}.json`))
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.code !== 'ENOENT') {
|
if (error.code === 'ENOENT') {
|
||||||
throw error
|
return user
|
||||||
}
|
}
|
||||||
|
|
||||||
|
throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,8 +74,8 @@ const getRoute = async (request, response) => {
|
||||||
const year = options.pinnedYear ?
|
const year = options.pinnedYear ?
|
||||||
options.pinnedYear :
|
options.pinnedYear :
|
||||||
removeFalsy([options.startYear, options.endYear]).join('-')
|
removeFalsy([options.startYear, options.endYear]).join('-')
|
||||||
const license = (options.license || user.license || 'MIT').toUpperCase()
|
const license = (options.license || user.license).toUpperCase()
|
||||||
const format = options.format || user.format || 'html'
|
const format = options.format || user.format
|
||||||
const isPlainText = format !== 'html'
|
const isPlainText = format !== 'html'
|
||||||
|
|
||||||
let name
|
let name
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue