mirror of
https://github.com/echore/vault-autopilot.git
synced 2026-07-22 08:34:00 +00:00
fix: strip Obsidian-reserved chars [ ] # ^ from filenames
Titles like '[Official Video]' or 'C#' produced names Obsidian rejects or that break the ![[...]] embed syntax. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
7f5d9f15cc
commit
362cddf39d
2 changed files with 6 additions and 1 deletions
|
|
@ -5,7 +5,7 @@ export function postProcessMarkdown(md: string): string {
|
|||
}
|
||||
|
||||
export function sanitize(str: string): string {
|
||||
return (str || '').replace(/[/\\:*?"<>|]/g, ' ').replace(/\s+/g, ' ').trim().slice(0, 60);
|
||||
return (str || '').replace(/[/\\:*?"<>|#^\[\]]/g, ' ').replace(/\s+/g, ' ').trim().slice(0, 60);
|
||||
}
|
||||
|
||||
// Guard for URLs we fetch on behalf of the client (covers, thumbnails): only
|
||||
|
|
|
|||
|
|
@ -31,6 +31,11 @@ describe('sanitize', () => {
|
|||
test('returns empty string for undefined input', () => {
|
||||
expect(sanitize(undefined as any)).toBe('');
|
||||
});
|
||||
test('strips Obsidian-reserved chars [ ] # ^ common in video titles', () => {
|
||||
expect(sanitize('[Official Video] Song')).toBe('Official Video Song');
|
||||
expect(sanitize('C# tutorial')).toBe('C tutorial');
|
||||
expect(sanitize('Video [4K] ^best^')).toBe('Video 4K best');
|
||||
});
|
||||
});
|
||||
|
||||
describe('extractVideoId', () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue