From 33dbe0a102ce5e46cd5a40a55d5ef6649f22e983 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Fri, 22 Jul 2022 17:54:16 +0800 Subject: [PATCH] feat(gui-v2): importUrlValidator --- packages/nc-gui-v2/utils/validation.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/nc-gui-v2/utils/validation.ts b/packages/nc-gui-v2/utils/validation.ts index 7bd40613d2..3ccb30db73 100644 --- a/packages/nc-gui-v2/utils/validation.ts +++ b/packages/nc-gui-v2/utils/validation.ts @@ -82,3 +82,16 @@ export const fieldRequiredValidator = { required: true, message: 'Field is required', } + +export const importUrlValidator = { + validator: (rule: any, value: any, callback: (errMsg?: string) => void) => { + if ( + /(10)(\.([2]([0-5][0-5]|[01234][6-9])|[1][0-9][0-9]|[1-9][0-9]|[0-9])){3}|(172)\.(1[6-9]|2[0-9]|3[0-1])(\.(2[0-4][0-9]|25[0-5]|[1][0-9][0-9]|[1-9][0-9]|[0-9])){2}|(192)\.(168)(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])){2}|(0.0.0.0)|localhost?/g.test( + value, + ) + ) { + callback('IP Not allowed!') + } + callback() + }, +}