diff --git a/package.json b/package.json index db5ca442..103aa55a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "photon-lemmy", - "version": "0.9.9", + "version": "0.9.10", "private": true, "scripts": { "dev": "vite dev", diff --git a/src/lib/components/markdown/markdown.ts b/src/lib/components/markdown/markdown.ts index b88cee7d..f53e4959 100644 --- a/src/lib/components/markdown/markdown.ts +++ b/src/lib/components/markdown/markdown.ts @@ -96,3 +96,19 @@ md.linkify.add('@', { match.url = `/u/${match.url.slice(1)}` }, }) + +md.linkify.add('https:', { + validate: function (text, pos, self) { + const tail = text.slice(pos) + + return tail.length + }, + normalize: function (match) { + const matched = match.url.match(/\/\/([\w-]+.[\w.]+)\/post\/(\d+)/) + if (!matched?.[1] || !matched?.[2]) { + return match + } + match.url = `/post/${matched?.[1]}/${matched?.[2]}` + console.log(match) + }, +}) diff --git a/src/routes/post/[instance]/[id=integer]/+page.svelte b/src/routes/post/[instance]/[id=integer]/+page.svelte index 4355e706..06f8f1a9 100644 --- a/src/routes/post/[instance]/[id=integer]/+page.svelte +++ b/src/routes/post/[instance]/[id=integer]/+page.svelte @@ -19,7 +19,7 @@ import MultiSelect from '$lib/components/input/MultiSelect.svelte' import { profile } from '$lib/auth.js' import { instance } from '$lib/instance.js' - import { goto } from '$app/navigation' + import { afterNavigate, goto } from '$app/navigation' import CommunityLink from '$lib/components/lemmy/community/CommunityLink.svelte' import Link from '$lib/components/input/Link.svelte' import SectionTitle from '$lib/components/ui/SectionTitle.svelte' @@ -34,7 +34,9 @@ post_id: data.post.post_view.post.id, }) } + }) + afterNavigate(async () => { if ( $page.params.instance.toLowerCase() != $instance.toLowerCase() && $profile?.jwt