diff --git a/package.json b/package.json
index 6adf4e03..6041203b 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "photon-lemmy",
- "version": "1.8.2",
+ "version": "1.8.3",
"private": true,
"scripts": {
"dev": "vite dev",
diff --git a/src/lib/components/markdown/Markdown.svelte b/src/lib/components/markdown/Markdown.svelte
index 13461191..e7037d47 100644
--- a/src/lib/components/markdown/Markdown.svelte
+++ b/src/lib/components/markdown/Markdown.svelte
@@ -5,10 +5,13 @@
export let source: string = ''
export let inline: boolean = false
- function replaceURLs(node: HTMLElement) {
+ function replaceURLs(node: HTMLElement, source: string) {
+ if (!div) return
+ console.log('replacing source', source)
const links = node.querySelectorAll('a')
links.forEach((l) => {
+ console.log('replacing link', l.href)
const photonified = photonify(l.href)
if (photonified) l.href = photonified
})
@@ -16,9 +19,7 @@
let div: HTMLElement
- $: if (source && div) {
- replaceURLs(div)
- }
+ $: replaceURLs(div, source)
diff --git a/src/lib/ui/image.ts b/src/lib/ui/image.ts
index f884783c..71b2c90b 100644
--- a/src/lib/ui/image.ts
+++ b/src/lib/ui/image.ts
@@ -1,13 +1,19 @@
export const isImage = (url: string | undefined) => {
- if (!url) return false
+ try {
+ if (!url) return false
- return /\.(jpeg|jpg|gif|png|svg|bmp|webp)$/i.test(new URL(url).pathname)
+ return /\.(jpeg|jpg|gif|png|svg|bmp|webp)$/i.test(new URL(url).pathname)
+ } catch (err) {
+ return false
+ }
}
-export const isVideo = (inputUrl: string | undefined) => {
- if (!inputUrl) return false
+export const isVideo = (url: string | undefined) => {
+ try {
+ if (!url) return false
- const url = new URL(inputUrl).pathname.toLowerCase()
-
- return url.endsWith('mp4') || url.endsWith('webm') || url.endsWith('mov') || url.endsWith('m4v')
+ return /\.(mp4|mov|webm|mkv)$/i.test(new URL(url).pathname)
+ } catch (err) {
+ return false
+ }
}
diff --git a/src/routes/util/+layout.svelte b/src/routes/util/+layout.svelte
new file mode 100644
index 00000000..6481fc1e
--- /dev/null
+++ b/src/routes/util/+layout.svelte
@@ -0,0 +1,30 @@
+
+
+
{
+ goto(e.detail)
+ }}
+/>
+
+
+
diff --git a/src/routes/util/+page.svelte b/src/routes/util/+page.svelte
new file mode 100644
index 00000000..782e16d5
--- /dev/null
+++ b/src/routes/util/+page.svelte
@@ -0,0 +1,5 @@
+Utilities
+
+ These are mostly for debugging purposes but you can use them to see how Photon
+ works on the inside. (if you don't feel like reading the source code)
+
diff --git a/src/routes/util/constants/+page.svelte b/src/routes/util/constants/+page.svelte
new file mode 100644
index 00000000..3a647e75
--- /dev/null
+++ b/src/routes/util/constants/+page.svelte
@@ -0,0 +1,34 @@
+
+
+Constants
+Constants used throughout the app.
+
+
+
+
+ | Name |
+ Value |
+
+
+
+
+ | DOMAIN_REGEX |
+ {DOMAIN_REGEX_FORMS} |
+
+
+
+
+
diff --git a/src/routes/util/functions/+page.svelte b/src/routes/util/functions/+page.svelte
new file mode 100644
index 00000000..ae7d50f8
--- /dev/null
+++ b/src/routes/util/functions/+page.svelte
@@ -0,0 +1,20 @@
+
+
+Functions
+Various utility functions.
+
+Images
+
+Image: {inputIsImage}
+Video: {inputIsVideo}
diff --git a/src/routes/util/photonify/+page.svelte b/src/routes/util/photonify/+page.svelte
new file mode 100644
index 00000000..62dfe05c
--- /dev/null
+++ b/src/routes/util/photonify/+page.svelte
@@ -0,0 +1,20 @@
+
+
+Photonify links
+Convert a link from a Lemmy post to a Photon link.
+
+
+
+
+
diff --git a/src/routes/util/placeholder/+page.svelte b/src/routes/util/placeholder/+page.svelte
new file mode 100644
index 00000000..461b34ac
--- /dev/null
+++ b/src/routes/util/placeholder/+page.svelte
@@ -0,0 +1,38 @@
+
+
+Placeholders
+
+ Photon randomly generates placeholders for use in text inputs and stuff. If
+ you have "Random Placeholders" disabled in settings, they will be empty.
+
+
+Posts
+
+ {post}
+
+
+
+Comments
+
+ {comment}
+
+
+
+Urls
+
+ {url}
+
+