summaryrefslogtreecommitdiffstats
path: root/ui/src/utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'ui/src/utils.ts')
-rw-r--r--ui/src/utils.ts10
1 files changed, 10 insertions, 0 deletions
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 {