From c01d1a6480715c45cd4b237f87ae7c48cb4620f9 Mon Sep 17 00:00:00 2001 From: aidenlx <31102694+aidenlx@users.noreply.github.com> Date: Thu, 15 Feb 2024 17:12:24 +0800 Subject: [PATCH] fix(protocol): fix protocol url not applied to timestamp link --- apps/app/src/media-note/timestamp/utils.ts | 8 +++----- apps/app/src/web/url-match/index.ts | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/apps/app/src/media-note/timestamp/utils.ts b/apps/app/src/media-note/timestamp/utils.ts index 96d396a2..1590ac2b 100644 --- a/apps/app/src/media-note/timestamp/utils.ts +++ b/apps/app/src/media-note/timestamp/utils.ts @@ -1,7 +1,6 @@ import type { MediaState } from "@vidstack/react"; import type { Editor } from "obsidian"; import { formatDuration, toTempFragString } from "@/lib/hash/format"; -import { noHash } from "@/lib/url"; import type { PlayerComponent } from "@/media-view/base"; import { isFileMediaInfo } from "@/media-view/media-info"; import type { MediaInfo, FileMediaInfo } from "@/media-view/media-info"; @@ -73,10 +72,9 @@ export function openOrCreateMediaNote( sourcePath: file.path, }); } else { - const sourceUrl = mediaInfo.mxUrl ?? mediaInfo.cleaned; return playerComponent.plugin.leafOpener.openNote(mediaInfo, { title: urlTitle(mediaInfo, player.state), - fm: () => ({ media: noHash(sourceUrl) }), + fm: () => ({ media: mediaInfo.jsonState.source }), }); } } @@ -104,7 +102,7 @@ export function timestampGenerator( .generateMarkdownLink(file, newNotePath, hash, timeInDuration) .replace(/^!/, ""); } else { - const sourceUrl = mediaInfo.cleaned; - return () => `[${timeInDuration}](${noHash(sourceUrl)}${hash})`; + const sourceUrl = mediaInfo.jsonState.source; + return () => `[${timeInDuration}](${sourceUrl}${hash})`; } } diff --git a/apps/app/src/web/url-match/index.ts b/apps/app/src/web/url-match/index.ts index 6c93081e..61498810 100644 --- a/apps/app/src/web/url-match/index.ts +++ b/apps/app/src/web/url-match/index.ts @@ -2,7 +2,7 @@ import type { TFile, Vault } from "obsidian"; import { Platform } from "obsidian"; import { addTempFrag, removeTempFrag } from "@/lib/hash/format"; import { parseTempFrag, type TempFragment } from "@/lib/hash/temporal-frag"; -import { noHashUrl } from "@/lib/url"; +import { noHash, noHashUrl } from "@/lib/url"; import { checkMediaType, type MediaType } from "@/patch/media-type"; import type { MxSettings } from "@/settings/def"; import type { URLResolveResult, URLResolver } from "./base"; @@ -85,7 +85,7 @@ export class MediaURL extends URL implements URLResolveResult { readonly type: MediaHost; get jsonState(): { source: string } { - return { source: this.mxUrl?.href ?? this.href }; + return { source: noHash(this.mxUrl ?? this.cleaned) }; } mxUrl: URL | null;