File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
shared/markdown/editing/modes Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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" ;
3133import { htmlToMarkdown } from "#/helpers/markdown" ;
3234import { 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 ;
You can’t perform that action at this time.
0 commit comments