@vaadin/upload 23.3.7 → 23.3.9
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 +9 -9
- package/src/vaadin-upload.js +22 -6
- package/web-types.json +1 -1
- package/web-types.lit.json +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/upload",
|
|
3
|
-
"version": "23.3.
|
|
3
|
+
"version": "23.3.9",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -36,16 +36,16 @@
|
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@polymer/polymer": "^3.0.0",
|
|
39
|
-
"@vaadin/button": "~23.3.
|
|
40
|
-
"@vaadin/component-base": "~23.3.
|
|
41
|
-
"@vaadin/progress-bar": "~23.3.
|
|
42
|
-
"@vaadin/vaadin-lumo-styles": "~23.3.
|
|
43
|
-
"@vaadin/vaadin-material-styles": "~23.3.
|
|
44
|
-
"@vaadin/vaadin-themable-mixin": "~23.3.
|
|
39
|
+
"@vaadin/button": "~23.3.9",
|
|
40
|
+
"@vaadin/component-base": "~23.3.9",
|
|
41
|
+
"@vaadin/progress-bar": "~23.3.9",
|
|
42
|
+
"@vaadin/vaadin-lumo-styles": "~23.3.9",
|
|
43
|
+
"@vaadin/vaadin-material-styles": "~23.3.9",
|
|
44
|
+
"@vaadin/vaadin-themable-mixin": "~23.3.9"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@esm-bundle/chai": "^4.3.4",
|
|
48
|
-
"@vaadin/form-layout": "~23.3.
|
|
48
|
+
"@vaadin/form-layout": "~23.3.9",
|
|
49
49
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
50
50
|
"sinon": "^13.0.2"
|
|
51
51
|
},
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"web-types.json",
|
|
54
54
|
"web-types.lit.json"
|
|
55
55
|
],
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "e4d0f83bb9f0fc992b115358f0ffd672504f144a"
|
|
57
57
|
}
|
package/src/vaadin-upload.js
CHANGED
|
@@ -432,6 +432,26 @@ class Upload extends ElementMixin(ThemableMixin(PolymerElement)) {
|
|
|
432
432
|
};
|
|
433
433
|
}
|
|
434
434
|
|
|
435
|
+
/** @private */
|
|
436
|
+
get __acceptRegexp() {
|
|
437
|
+
if (!this.accept) {
|
|
438
|
+
return null;
|
|
439
|
+
}
|
|
440
|
+
const processedTokens = this.accept.split(',').map((token) => {
|
|
441
|
+
let processedToken = token.trim();
|
|
442
|
+
// Escape regex operators common to mime types
|
|
443
|
+
processedToken = processedToken.replace(/[+.]/g, '\\$&');
|
|
444
|
+
// Make extension patterns match the end of the file name
|
|
445
|
+
if (processedToken.startsWith('\\.')) {
|
|
446
|
+
processedToken = `.*${processedToken}$`;
|
|
447
|
+
}
|
|
448
|
+
// Handle star (*) wildcards
|
|
449
|
+
return processedToken.replace(/\/\*/g, '/.*');
|
|
450
|
+
});
|
|
451
|
+
// Create accept regex
|
|
452
|
+
return new RegExp(`^(${processedTokens.join('|')})$`, 'i');
|
|
453
|
+
}
|
|
454
|
+
|
|
435
455
|
/** @protected */
|
|
436
456
|
ready() {
|
|
437
457
|
super.ready();
|
|
@@ -779,12 +799,8 @@ class Upload extends ElementMixin(ThemableMixin(PolymerElement)) {
|
|
|
779
799
|
);
|
|
780
800
|
return;
|
|
781
801
|
}
|
|
782
|
-
const
|
|
783
|
-
|
|
784
|
-
const escapedAccept = this.accept.replace(/[+.]/g, '\\$&');
|
|
785
|
-
// Create accept regex that can match comma separated patterns, star (*) wildcards
|
|
786
|
-
const re = new RegExp(`^(${escapedAccept.replace(/[, ]+/g, '|').replace(/\/\*/g, '/.*')})$`, 'i');
|
|
787
|
-
if (this.accept && !(re.test(file.type) || re.test(fileExt))) {
|
|
802
|
+
const re = this.__acceptRegexp;
|
|
803
|
+
if (re && !(re.test(file.type) || re.test(file.name))) {
|
|
788
804
|
this.dispatchEvent(
|
|
789
805
|
new CustomEvent('file-reject', {
|
|
790
806
|
detail: { file, error: this.i18n.error.incorrectFileType },
|
package/web-types.json
CHANGED