Skip to content

Commit

Permalink
Merge pull request #21 from b-yp/dev
Browse files Browse the repository at this point in the history
fix: Exclude special characters from the name
  • Loading branch information
b-yp authored Dec 18, 2023
2 parents 212297f + afe4f73 commit 14521ad
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ export const useAppVisible = () => {
return React.useSyncExternalStore(subscribeToUIVisible, () => _visible);
};

// https://github.com/b-yp/logseq-link-to-local/issues/20
const replaceSpecialCharacters = (inputString: string): string => {
const regex = /[/\\?%*:|"<>.;,= ]/g;
const result = inputString.replace(regex, '_');
return result;
}

// 用于匹配 markdown 格式图片和你 直接链接图片, GPT4 给的匹配函数
export const findImageLinks = (text: string | undefined = '', id: number | undefined = 0): ImageLink[] => {
if (!text) return [];
Expand Down Expand Up @@ -67,7 +74,7 @@ export const findImageLinks = (text: string | undefined = '', id: number | undef
url,
params,
fullName,
name,
name: replaceSpecialCharacters(name),
type: getType(),
description
});
Expand Down Expand Up @@ -96,7 +103,7 @@ export const findImageLinks = (text: string | undefined = '', id: number | undef
url,
params,
fullName,
name,
name: replaceSpecialCharacters(name),
type,
description: ''
});
Expand Down

0 comments on commit 14521ad

Please sign in to comment.