mirror of
https://github.com/kdnk/obsidian-automatic-linker.git
synced 2026-07-22 12:00:30 +00:00
13 lines
441 B
TypeScript
13 lines
441 B
TypeScript
import { AutomaticLinkerSettings } from "../settings/settings-info";
|
|
|
|
export const replaceURLs = (
|
|
fileContent: string,
|
|
settings: AutomaticLinkerSettings,
|
|
formatter: (url: string, settings: AutomaticLinkerSettings) => string,
|
|
) => {
|
|
const githubUrlPattern = /(?<!\[\[.*)(https?:\/\/[^\s\]]+)(?!.*\]\])/g;
|
|
fileContent = fileContent.replace(githubUrlPattern, (match) => {
|
|
return formatter(match, settings);
|
|
});
|
|
return fileContent;
|
|
};
|