2025-01-18 12:52:59 -05:00
|
|
|
import { Plugin } from 'obsidian';
|
|
|
|
|
|
|
|
const UNSAFE_CHAR_REGEX = /[*?<>"]/g;
|
|
|
|
|
|
|
|
export default class SafeFilenames extends Plugin {
|
|
|
|
async onload() {
|
|
|
|
this.registerEvent(this.app.vault.on('rename', (file, oldPath) => {
|
|
|
|
if (UNSAFE_CHAR_REGEX.test(file.path)) {
|
|
|
|
this.app.fileManager.renameFile(file, file.path.replaceAll(UNSAFE_CHAR_REGEX, ''));
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
}
|
2022-04-15 14:13:31 -04:00
|
|
|
}
|