Added URL validator

This commit is contained in:
Sebastian Seedorf
2020-05-27 01:51:47 +02:00
parent d33ce96d18
commit d0cea00ff4
2 changed files with 104 additions and 5 deletions

View File

@@ -38,17 +38,27 @@ Deno.test("isString (no match)", async () => {
Deno.test("isURL (match)", async () => {
const values = [
"http://google.com",
"http://10.1.1.1",
"http://10.1.1.254",
"http://223.255.255.254",
" data:,Hello World!"
];
for (const value of values) {
assertEquals(await validate(value, isURL()), []);
assertEquals(await validate(value, isURL({allowLocal: true, allowDataUrl: true})), [], value);
}
});
Deno.test("isURL (no match)", async () => {
const values = [
"invalid",
"http://0.0.0.0",
"http://10.1.1.0",
"http://10.1.1.255",
"http://224.1.1.1",
"http://1.1.1.1.1",
" data:,Hello World!"
];
for (const value of values) {
assertNotEquals(await validate(value, isURL()), []);
assertNotEquals(await validate(value, isURL({allowLocal: true})), [], value);
}
});