added validator js

ref #13
This commit is contained in:
2021-04-07 19:03:48 +02:00
parent 517cfddc5f
commit 0cea262ac5
3 changed files with 50 additions and 31 deletions

View File

@@ -1,5 +1,7 @@
<script>
import { apikey, lang, stationinfo } from "./store.js";
import isURL from 'validator/lib/isURL';
import isUUID from 'validator/lib/isUUID';
import axios from "axios";
import { _, locale } from "svelte-i18n";
let token;
@@ -9,20 +11,6 @@
token?.length === 44 &&
token.split(".")[0].length === 7 &&
isUUID(token.split(".")[1]);
function isLocale(l) {
return $locale == l;
}
function isUUID(uuid) {
let s = "" + uuid;
s = s.match(
"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
);
if (s === null) {
return false;
}
return true;
}
</script>
<div class="w-full flex flex-wrap">