Normalizes output folder path for settings

Ensures that the output folder path is normalized before being saved in the settings. This prevents issues with inconsistent or invalid paths.
This commit is contained in:
AlexKucera committed 2025-09-04 22:30:06 +02:00
1 parent 151dc537a5
commit 21fdfbf207
2 files changed
+10 -7

No files matched your search

+6 -4
View File
@@ -16,7 +16,8 @@ import {
Menu,
MarkdownView,
Editor,
AbstractInputSuggest
AbstractInputSuggest,
normalizePath
} from 'obsidian';
import { obsidianTypstPDFExportSettings, DEFAULT_SETTINGS, ExportFormat } from './src/core/settings';
@@ -1265,11 +1266,12 @@ class ObsidianTypstPDFExportSettingTab extends PluginSettingTab {
.setPlaceholder('exports')
.setValue(this.plugin.settings.outputFolder)
.onChange(async (value) => {
if (!SecurityUtils.validateOutputPath(value)) {
new Notice(`Invalid output folder: ${SecurityUtils.getPathValidationError(value)}`);
const normalizedValue = normalizePath(value);
if (!SecurityUtils.validateOutputPath(normalizedValue)) {
new Notice(`Invalid output folder: ${SecurityUtils.getPathValidationError(normalizedValue)}`);
return;
}
this.plugin.settings.outputFolder = value;
this.plugin.settings.outputFolder = normalizedValue;
await this.plugin.saveSettings();
});
+4 -3
View File
@@ -3,7 +3,7 @@
* Handles template selection, format options, and output settings
*/
import { Setting, App } from 'obsidian';
import { Setting, App, normalizePath } from 'obsidian';
import { ModalSection, ModalState, ValidationResult } from '../modalTypes';
import { ExportFormat } from '../../../core/settings';
import { FolderSuggest } from '../../components/FolderSuggest';
@@ -78,7 +78,8 @@ export class GeneralSection implements ModalSection {
.setPlaceholder('exports')
.setValue(state.settings.outputFolder || 'exports')
.onChange(value => {
state.updateSettings({ outputFolder: value });
const normalizedValue = normalizePath(value);
state.updateSettings({ outputFolder: normalizedValue });
});
this.outputFolderInput = input.inputEl;
@@ -101,7 +102,7 @@ export class GeneralSection implements ModalSection {
// Validate output folder
if (this.outputFolderInput) {
const value = this.outputFolderInput.value.trim();
const value = normalizePath(this.outputFolderInput.value.trim());
if (!SecurityUtils.validateOutputPath(value)) {
errors.push(SecurityUtils.getPathValidationError(value));
}