mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-07-11 08:43:48 +00:00
fix: Match skill frontmatter closing fence
This commit is contained in:
parent
6e6e5a29f4
commit
432227055c
2 changed files with 14 additions and 3 deletions
|
|
@ -188,6 +188,16 @@ describe('parseFrontmatter', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('does not treat frontmatter scalar lines that start with --- text as closing fences', () => {
|
||||
const raw = `---\nname: marker\ndescription: 'first\n---not a closing fence\nlast'\nalways-apply: false\n---\n\nbody`;
|
||||
expect(parseFrontmatter(raw)).toEqual({
|
||||
name: 'marker',
|
||||
description: 'first ---not a closing fence last',
|
||||
alwaysApply: false,
|
||||
invalidBooleans: [],
|
||||
});
|
||||
});
|
||||
|
||||
it('returns empty fields when frontmatter is unterminated', () => {
|
||||
const raw = `---\nname: incomplete\n`;
|
||||
expect(parseFrontmatter(raw)).toEqual({
|
||||
|
|
|
|||
|
|
@ -23,11 +23,12 @@ function extractFrontmatterBlock(raw: string): string | null {
|
|||
if (!content.startsWith('---\n')) {
|
||||
return null;
|
||||
}
|
||||
const closingIdx = content.indexOf('\n---', 4);
|
||||
if (closingIdx === -1) {
|
||||
const body = content.slice(4);
|
||||
const closingFence = /(?:^|\n)---[ \t]*(?:\n|$)/.exec(body);
|
||||
if (!closingFence) {
|
||||
return null;
|
||||
}
|
||||
return content.slice(4, closingIdx);
|
||||
return body.slice(0, closingFence.index);
|
||||
}
|
||||
|
||||
function getCaseInsensitive(frontmatter: Record<string, unknown>, key: string): unknown {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue