From 778a0a5ff17c3eb6b6b5aa3173eeae8e0e0cc774 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Fri, 16 Aug 2019 18:46:39 -0700 Subject: Fixing create post bug. - Fixes #202 --- ui/src/utils.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'ui/src/utils.ts') diff --git a/ui/src/utils.ts b/ui/src/utils.ts index c48b00c6..c6f43c94 100644 --- a/ui/src/utils.ts +++ b/ui/src/utils.ts @@ -84,6 +84,16 @@ export function isImage(url: string) { return imageRegex.test(url); } +export function validURL(str: string) { + var pattern = new RegExp('^(https?:\\/\\/)?'+ // protocol + '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|'+ // domain name + '((\\d{1,3}\\.){3}\\d{1,3}))'+ // OR ip (v4) address + '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+ // port and path + '(\\?[;&a-z\\d%_.~+=-]*)?'+ // query string + '(\\#[-a-z\\d_]*)?$','i'); // fragment locator + return !!pattern.test(str); +} + export let fetchLimit: number = 20; export function capitalizeFirstLetter(str: string): string { -- cgit v1.2.3