@webiny/validation 6.3.0-beta.2 → 6.3.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -4
- package/validators/url.js +1 -1
- package/validators/url.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/validation",
|
|
3
|
-
"version": "6.3.0-beta.
|
|
3
|
+
"version": "6.3.0-beta.4",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./index.js",
|
|
7
|
+
"./*": "./*"
|
|
8
|
+
},
|
|
6
9
|
"repository": {
|
|
7
10
|
"type": "git",
|
|
8
11
|
"url": "https://github.com/webiny/webiny-js.git"
|
|
@@ -19,7 +22,7 @@
|
|
|
19
22
|
},
|
|
20
23
|
"devDependencies": {
|
|
21
24
|
"@types/lodash": "4.17.24",
|
|
22
|
-
"@webiny/build-tools": "6.3.0-beta.
|
|
25
|
+
"@webiny/build-tools": "6.3.0-beta.4",
|
|
23
26
|
"rimraf": "6.1.3",
|
|
24
27
|
"typescript": "6.0.3",
|
|
25
28
|
"vitest": "4.1.5"
|
|
@@ -28,5 +31,5 @@
|
|
|
28
31
|
"access": "public",
|
|
29
32
|
"directory": "dist"
|
|
30
33
|
},
|
|
31
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "7cefe15431dbd65504e1f58147dc9e55bcbfa693"
|
|
32
35
|
}
|
package/validators/url.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ValidationError from "../validationError.js";
|
|
2
2
|
const regex = {
|
|
3
|
-
base: new RegExp(/^(https?:\/\/)((([a-z\d]([a-z\d-]*[a-z\d])*)\.)+[a-z]{2,}|((\d{1,3}\.){3}\d{1,3}))(
|
|
3
|
+
base: new RegExp(/^(https?:\/\/)((([a-z\d]([a-z\d-]*[a-z\d])*)\.)+[a-z]{2,}|((\d{1,3}\.){3}\d{1,3}))(:\d+)?(\/[-a-z\d%_.~+]*)*(\?[;&a-z\d%_.~+=!-]*)?(#[-a-z\d_]*)?$/i),
|
|
4
4
|
ip: new RegExp(/^(https?:\/\/)(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/),
|
|
5
5
|
relative: new RegExp(/^\/.*$/),
|
|
6
6
|
href: new RegExp(/^(#|mailto:|tel:)\S*$/)
|
package/validators/url.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ValidationError","regex","base","RegExp","ip","relative","href","value","params","startsWith","replace","test","includes"],"sources":["url.ts"],"sourcesContent":["import ValidationError from \"~/validationError.js\";\n\nconst regex = {\n base: new RegExp(\n /^(https?:\\/\\/)((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(
|
|
1
|
+
{"version":3,"names":["ValidationError","regex","base","RegExp","ip","relative","href","value","params","startsWith","replace","test","includes"],"sources":["url.ts"],"sourcesContent":["import ValidationError from \"~/validationError.js\";\n\nconst regex = {\n base: new RegExp(\n /^(https?:\\/\\/)((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=!-]*)?(#[-a-z\\d_]*)?$/i\n ),\n ip: new RegExp(\n /^(https?:\\/\\/)(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/\n ),\n relative: new RegExp(/^\\/.*$/),\n href: new RegExp(/^(#|mailto:|tel:)\\S*$/)\n};\n\nexport default (value: any, params?: string[]) => {\n if (!value || !params) {\n return;\n }\n value = value + \"\";\n\n if (value.startsWith(\"http://localhost\") || value.startsWith(\"https://localhost\")) {\n value = value.replace(\"//localhost\", \"//localhost.com\");\n }\n\n if (regex.base.test(value)) {\n if (!params.includes(\"noIp\")) {\n return;\n }\n\n if (!regex.ip.test(value)) {\n return;\n }\n }\n\n if (params.includes(\"allowRelative\")) {\n if (regex.relative.test(value)) {\n return;\n }\n }\n\n if (params.includes(\"allowHref\")) {\n if (regex.href.test(value)) {\n return;\n }\n }\n\n throw new ValidationError(\"Value must be a valid URL.\");\n};\n"],"mappings":"AAAA,OAAOA,eAAe;AAEtB,MAAMC,KAAK,GAAG;EACVC,IAAI,EAAE,IAAIC,MAAM,CACZ,qJACJ,CAAC;EACDC,EAAE,EAAE,IAAID,MAAM,CACV,+KACJ,CAAC;EACDE,QAAQ,EAAE,IAAIF,MAAM,CAAC,QAAQ,CAAC;EAC9BG,IAAI,EAAE,IAAIH,MAAM,CAAC,uBAAuB;AAC5C,CAAC;AAED,eAAe,CAACI,KAAU,EAAEC,MAAiB,KAAK;EAC9C,IAAI,CAACD,KAAK,IAAI,CAACC,MAAM,EAAE;IACnB;EACJ;EACAD,KAAK,GAAGA,KAAK,GAAG,EAAE;EAElB,IAAIA,KAAK,CAACE,UAAU,CAAC,kBAAkB,CAAC,IAAIF,KAAK,CAACE,UAAU,CAAC,mBAAmB,CAAC,EAAE;IAC/EF,KAAK,GAAGA,KAAK,CAACG,OAAO,CAAC,aAAa,EAAE,iBAAiB,CAAC;EAC3D;EAEA,IAAIT,KAAK,CAACC,IAAI,CAACS,IAAI,CAACJ,KAAK,CAAC,EAAE;IACxB,IAAI,CAACC,MAAM,CAACI,QAAQ,CAAC,MAAM,CAAC,EAAE;MAC1B;IACJ;IAEA,IAAI,CAACX,KAAK,CAACG,EAAE,CAACO,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