Skip to content

Commit 7f0a32c

Browse files
authored
fix: vger.to urls not unfurled in markdown url insert dialog (#2187)
1 parent 82c8b7f commit 7f0a32c

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/features/resolve/resolveSlice.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,14 @@ export function normalizeObjectUrl(objectUrl: string) {
130130
return url;
131131
}
132132

133-
export function unfurlRedirectServiceIfNeeded(url: string): string {
134-
const potentialUrl = extractLemmyLinkFromPotentialFediRedirectService(url);
133+
export function unfurlRedirectServiceIfNeeded(
134+
url: string,
135+
services?: string[],
136+
): string {
137+
const potentialUrl = extractLemmyLinkFromPotentialFediRedirectService(
138+
url,
139+
services,
140+
);
135141

136142
if (potentialUrl) return potentialUrl;
137143

src/features/shared/markdown/editing/modes/DefaultMode.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import {
2828
subscript,
2929
superscript,
3030
} from "#/features/icons";
31+
import { unfurlRedirectServiceIfNeeded } from "#/features/resolve/resolveSlice";
32+
import { GO_VOYAGER_HOST } from "#/features/share/fediRedirect";
3133
import { htmlToMarkdown } from "#/helpers/markdown";
3234
import { isValidUrl } from "#/helpers/url";
3335

@@ -237,8 +239,10 @@ export default function DefaultMode({
237239
});
238240
}
239241

240-
function insertMarkdownLink(text: string = "", url?: string) {
241-
const markdownLink = `[${text}](${url || "url"})`;
242+
function insertMarkdownLink(text = "", url = "") {
243+
const unwrappedUrl = unfurlRedirectServiceIfNeeded(url, [GO_VOYAGER_HOST]);
244+
245+
const markdownLink = `[${text}](${unwrappedUrl || "url"})`;
242246

243247
const locationBeforeInsert = selectionLocation.current;
244248
const currentSelectionLocation = locationBeforeInsert + markdownLink.length;

0 commit comments

Comments
 (0)