mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-27 12:08:02 -05:00
refactor(commons): remove redundant method
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
5443510a79
commit
20197d36df
1 changed files with 4 additions and 11 deletions
|
@ -66,14 +66,6 @@ const schema = Joi.object<RawNoteFrontmatter>({
|
|||
.default(defaultNoteFrontmatter)
|
||||
.unknown(true)
|
||||
|
||||
const loadYaml = (rawYaml: string): unknown => {
|
||||
try {
|
||||
return load(rawYaml)
|
||||
} catch {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
type ParserResult =
|
||||
| {
|
||||
error: undefined
|
||||
|
@ -87,9 +79,10 @@ type ParserResult =
|
|||
}
|
||||
|
||||
export const parseRawFrontmatterFromYaml = (rawYaml: string): ParserResult => {
|
||||
const rawNoteFrontmatter = loadYaml(rawYaml)
|
||||
if (rawNoteFrontmatter === undefined) {
|
||||
try {
|
||||
const rawNoteFrontmatter = load(rawYaml)
|
||||
return schema.validate(rawNoteFrontmatter, { convert: true })
|
||||
} catch {
|
||||
return { error: new Error('Invalid YAML'), value: undefined }
|
||||
}
|
||||
return schema.validate(rawNoteFrontmatter, { convert: true })
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue