Skip to content

Commit

Permalink
refactor: keep full string and quotations
Browse files Browse the repository at this point in the history
  • Loading branch information
decaf-dev committed Dec 26, 2023
1 parent 9898ca8 commit d28c961
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/commands/export-into-multiple-notes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { App, Command, Notice } from "obsidian";
import { exportBrowserTabs } from "src/export/export";
import { createFile, createFolder } from "src/utils/file-utils";
import { getFrontmatterForFile } from "src/utils/frontmatter-utils";
import { appendWebsiteTitle, findLongestString, getWebsiteTitle, removeQuotations, removeTrailingPeriod, removeWebsiteTitles, trimForObsidian } from "src/utils/title-utils";
import { appendWebsiteTitle, getWebsiteTitle, removeTrailingHyphen, removeTrailingPeriod, removeWebsiteTitles, trimForObsidian } from "src/utils/title-utils";
import { PluginSettings } from "src/types";
import { pipeline } from "src/utils/pipeline";
import { formatForFileSystem } from "src/utils/file-system-utils";
Expand Down Expand Up @@ -33,8 +33,8 @@ const callback = (app: App, settings: PluginSettings) => async () => {
for (const tab of tabs) {
const { title, url } = tab;

const titlePipeline = pipeline(formatForFileSystem, removeQuotations, removeWebsiteTitles, findLongestString, removeTrailingPeriod);
const titleString = titlePipeline(title);
const titlePipeline = pipeline(formatForFileSystem, removeWebsiteTitles, removeTrailingHyphen, removeTrailingPeriod);
const titleString = (titlePipeline(title) as string).trim();

const websiteTitle = getWebsiteTitle(url);
const trimmed = trimForObsidian(titleString as string, websiteTitle, "md");
Expand Down
4 changes: 4 additions & 0 deletions src/utils/title-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export const removeWebsiteTitles = (value: string) => {
return value;
}

export const removeTrailingHyphen = (value: string) => {
return value.replace(/-$/, "");
}

/**
* Finds the longest string in a string that is separated by a hyphen space `- ` or space hyphen ` -`
* @param value - The value to format
Expand Down

0 comments on commit d28c961

Please sign in to comment.