Skip to content

Commit

Permalink
fix(link): fix http url with inferred type opened in browser by default
Browse files Browse the repository at this point in the history
  • Loading branch information
aidenlx committed Feb 15, 2024
1 parent 652514e commit afca413
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions apps/app/src/media-note/link-click.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { MediaHost } from "@/web/url-match/supported";
function shouldOpenMedia(url: MediaURL, plugin: MxPlugin): boolean {
return !!(
url.type !== MediaHost.Generic ||
(url.isFileUrl && url.inferredType) ||
url.inferredType ||
url.tempFrag ||
plugin.mediaNote.findNotes(url).length > 0 ||
plugin.urlViewType.getPreferred(url, true)
Expand Down Expand Up @@ -44,7 +44,7 @@ export function handleExternalLinkMenu(plugin: MxPlugin) {
plugin.app.workspace.on("url-menu", (menu, link) => {
const url = plugin.resolveUrl(link);
if (!url) return;
const { protocol, hostname, pathname } = url;
const { protocol, hostname, pathname, host, port } = url;
const supported = plugin.urlViewType.getSupported(url);
const preferred = plugin.urlViewType.getPreferred(url);
const showInMenu = shouldOpenMedia(url, plugin)
Expand Down Expand Up @@ -82,7 +82,7 @@ export function handleExternalLinkMenu(plugin: MxPlugin) {
.setSection("mx-link")
.onClick(async () => {
plugin.urlViewType.setPreferred(
{ protocol, hostname, pathname },
{ protocol, hostname, pathname, port },
viewType,
);
await plugin.leafOpener.openMedia(url, undefined, {
Expand All @@ -95,7 +95,7 @@ export function handleExternalLinkMenu(plugin: MxPlugin) {
if (hostname)
menu.addItem((item) => {
const matchHostname = item
.setTitle(`Always open ${hostname} as`)
.setTitle(`Always open ${host} as`)
.setIcon("external-link")
.setSection("mx-link")
.setSubmenu();
Expand All @@ -105,7 +105,7 @@ export function handleExternalLinkMenu(plugin: MxPlugin) {
.setSection("mx-link")
.onClick(async () => {
plugin.urlViewType.setPreferred(
{ protocol, hostname },
{ protocol, hostname, port },
viewType,
);
await plugin.leafOpener.openMedia(url, undefined, {
Expand Down

0 comments on commit afca413

Please sign in to comment.