about summary refs log tree commit diff
path: root/client/src/utils/checkUrl.ts
diff options
context:
space:
mode:
authorMelonai <einebeere@gmail.com>2021-01-20 23:18:09 +0100
committerMelonai <einebeere@gmail.com>2021-01-20 23:18:09 +0100
commit826c7c47785ee01d2b9267919132ada696425344 (patch)
tree901cc90be9a953a6c3f968b6c1abe33cc13774b4 /client/src/utils/checkUrl.ts
parent2953dec527cedaabaa5f0eb48637c5ddd4a4103b (diff)
downloadshorest-826c7c47785ee01d2b9267919132ada696425344.tar.zst
shorest-826c7c47785ee01d2b9267919132ada696425344.zip
Remade the client in SvelteKit
Diffstat (limited to 'client/src/utils/checkUrl.ts')
-rw-r--r--client/src/utils/checkUrl.ts10
1 files changed, 10 insertions, 0 deletions
diff --git a/client/src/utils/checkUrl.ts b/client/src/utils/checkUrl.ts
new file mode 100644
index 0000000..8ed747f
--- /dev/null
+++ b/client/src/utils/checkUrl.ts
@@ -0,0 +1,10 @@
+import addProtocol from "./addProtocol";
+
+export default function (url: string): string | null {
+    try {
+        const normalizedUrl = new URL(addProtocol(url));
+        return normalizedUrl.toString();
+    } catch (e) {
+        return null;
+    }
+}
\ No newline at end of file