Skip to content

Commit

Permalink
Merge pull request #220 from DominikPieper/hotfix/emoji-filename
Browse files Browse the repository at this point in the history
hotfix: preserve emojis defined in filename template
  • Loading branch information
adamluckdev authored Jan 26, 2025
2 parents 395e81c + 2c9121c commit 000e388
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/helpers/fileutils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ export function getBaseUrl(url: string, origin: string): string {
return baseURL.href;
}

export function normalizeFilename(fileName: string): string {
export function normalizeFilename(fileName: string, preserveUnicode: boolean = true): string {
if (preserveUnicode) {
return fileName.replace(/[:#/\\|?*<>"]/g, '');
}

return fileName.replace(
/[:#/\\()|?*<>"[\u{1F300}-\u{1F9FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}\u{1F000}-\u{1F02F}\u{1F0A0}-\u{1F0FF}\u{1F100}-\u{1F64F}\u{1F680}-\u{1F6FF}]/gu,
'',
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/BlueskyParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export class BlueskyParser extends Parser {
const fileName = this.templateEngine.render(this.plugin.settings.blueskyNoteTitle, {
date: this.getFormattedDateForFilename(createdAt),
authorHandle: post.author.handle,
authorName: post.author.displayName,
authorName: normalizeFilename(post.author.displayName, false),
});

if (this.plugin.settings.downloadBlueskyEmbeds) {
Expand Down

0 comments on commit 000e388

Please sign in to comment.