neo.mjs 5.7.3 → 5.7.5
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/apps/ServiceWorker.mjs +2 -2
- package/examples/ServiceWorker.mjs +2 -2
- package/package.json +1 -1
- package/src/DefaultConfig.mjs +2 -2
- package/src/form/field/Url.mjs +11 -96
package/apps/ServiceWorker.mjs
CHANGED
package/package.json
CHANGED
package/src/DefaultConfig.mjs
CHANGED
@@ -236,12 +236,12 @@ const DefaultConfig = {
|
|
236
236
|
useVdomWorker: true,
|
237
237
|
/**
|
238
238
|
* buildScripts/injectPackageVersion.mjs will update this value
|
239
|
-
* @default '5.7.
|
239
|
+
* @default '5.7.5'
|
240
240
|
* @memberOf! module:Neo
|
241
241
|
* @name config.version
|
242
242
|
* @type String
|
243
243
|
*/
|
244
|
-
version: '5.7.
|
244
|
+
version: '5.7.5'
|
245
245
|
};
|
246
246
|
|
247
247
|
Object.assign(DefaultConfig, {
|
package/src/form/field/Url.mjs
CHANGED
@@ -19,107 +19,22 @@ class Url extends Text {
|
|
19
19
|
*/
|
20
20
|
ntype: 'urlfield',
|
21
21
|
/**
|
22
|
-
* @member {String}
|
22
|
+
* @member {String} errorTextInputPattern=data=>'Not a valid URL'
|
23
23
|
*/
|
24
|
-
|
24
|
+
errorTextInputPattern: data => 'Not a valid URL',
|
25
25
|
/**
|
26
|
-
*
|
27
|
-
* @member {String} inputType='url'
|
26
|
+
* @member {RegExp|null} inputPattern=/^(https?:\/\/)?(([a-zA-Z0-9_-]+\.)*([a-zA-Z0-9_-]+\.[a-zA-Z]{2,}))(\/([a-zA-Z0-9._-]+)\/?)*$/
|
28
27
|
*/
|
29
|
-
|
28
|
+
inputPattern: /^(https?:\/\/)?(([a-zA-Z0-9_-]+\.)*([a-zA-Z0-9_-]+\.[a-zA-Z]{2,}))(\/([a-zA-Z0-9._-]+)\/?)*$/,
|
30
29
|
/**
|
31
|
-
*
|
32
|
-
* 'none' means that user inputs like "www.google.com" will be considered as valid.
|
33
|
-
* @member {String[]} protocols=['http:','https:','none']
|
30
|
+
* @member {Boolean} inputPatternDOM=false
|
34
31
|
*/
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
* E.g. new URL("http:www.google.com").href => "http://www.google.com"
|
42
|
-
* @param {String|null} value
|
43
|
-
* @returns {String|null}
|
44
|
-
* @protected
|
45
|
-
*/
|
46
|
-
beforeGetValue(value) {
|
47
|
-
if (value) {
|
48
|
-
let me = this,
|
49
|
-
href = me.getUrl(value)?.href;
|
50
|
-
|
51
|
-
if (!href && me.protocols.includes('none')) {
|
52
|
-
href = me.getUrl(`https://${value}`)?.href;
|
53
|
-
|
54
|
-
if (href) {
|
55
|
-
href = href.replace('https://', '')
|
56
|
-
}
|
57
|
-
}
|
58
|
-
|
59
|
-
if (href) {
|
60
|
-
return href
|
61
|
-
}
|
62
|
-
}
|
63
|
-
|
64
|
-
return value
|
65
|
-
}
|
66
|
-
|
67
|
-
/**
|
68
|
-
* Returns false in case an URL could not get created
|
69
|
-
* @param {String} value
|
70
|
-
* @returns {Boolean|URL}
|
71
|
-
*/
|
72
|
-
getUrl(value) {
|
73
|
-
let url;
|
74
|
-
|
75
|
-
try {
|
76
|
-
url = new URL(value);
|
77
|
-
} catch(e) {
|
78
|
-
return false
|
79
|
-
}
|
80
|
-
|
81
|
-
return url
|
82
|
-
}
|
83
|
-
|
84
|
-
/**
|
85
|
-
* Checks for client-side field errors
|
86
|
-
* @param {Boolean} silent=true
|
87
|
-
* @returns {Boolean} Returns true in case there are no client-side errors
|
88
|
-
*/
|
89
|
-
validate(silent=true) {
|
90
|
-
let me = this,
|
91
|
-
returnValue = super.validate(silent),
|
92
|
-
value = me.value;
|
93
|
-
|
94
|
-
if (returnValue) {
|
95
|
-
if (value && !me.verifyUrl(value)) {
|
96
|
-
me._error = me.errorTextValidUrl;
|
97
|
-
returnValue = false;
|
98
|
-
}
|
99
|
-
}
|
100
|
-
|
101
|
-
!returnValue && !me.clean && me.updateError(me._error, silent);
|
102
|
-
|
103
|
-
return returnValue
|
104
|
-
}
|
105
|
-
|
106
|
-
/**
|
107
|
-
* @param {String} value
|
108
|
-
* @returns {Boolean}
|
109
|
-
*/
|
110
|
-
verifyUrl(value) {
|
111
|
-
let me = this,
|
112
|
-
url = me.getUrl(value);
|
113
|
-
|
114
|
-
if (!url && me.protocols.includes('none')) {
|
115
|
-
url = me.getUrl(`https://${value}`);console.log(url)
|
116
|
-
}
|
117
|
-
|
118
|
-
if (!url) {
|
119
|
-
return false
|
120
|
-
}
|
121
|
-
|
122
|
-
return me.protocols.includes(url.protocol)
|
32
|
+
inputPatternDOM: false,
|
33
|
+
/**
|
34
|
+
* Value for the inputType_ textfield config
|
35
|
+
* @member {String} inputType='url'
|
36
|
+
*/
|
37
|
+
inputType: 'url'
|
123
38
|
}
|
124
39
|
}
|
125
40
|
|