Skip to content

Commit

Permalink
fix: ensure exported preferences file has .txt extension
Browse files Browse the repository at this point in the history
  • Loading branch information
onemen committed Feb 12, 2025
1 parent 78f317c commit 266a8b0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion addon/chrome/content/preferences/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,14 @@ function showFilePicker(mode) {
}
fp.appendFilters(nsIFilePicker.filterText);
fp.open(result => {
resolve(result != nsIFilePicker.returnCancel ? fp.file : null);
if (result === nsIFilePicker.returnOK) {
const fileName = fp.file.leafName;
if (!fileName.endsWith(".txt")) {
fp.file.leafName = fileName + ".txt";
}
return resolve(fp.file);
}
return resolve(null);
});
});
}
Expand Down
1 change: 1 addition & 0 deletions types/general.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,7 @@ declare namespace MockedExports {
// nsIFilePicker is missing some types from lib.gecko.xpcom.d.ts
interface nsIFilePicker extends nsIFilePickerXpcom {}
interface FilePicker extends Pick<nsIFilePicker, "appendFilters" | "defaultExtension" | "defaultString"> {
file: nsIFile;
init: (browsingContext: BrowsingContext, title: string | null, mode: number) => void;
}

Expand Down

0 comments on commit 266a8b0

Please sign in to comment.