@vaadin/upload 24.1.0-alpha1 → 24.1.0-alpha3
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": "24.1.0-
|
|
3
|
+
"version": "24.1.0-alpha3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@polymer/polymer": "^3.0.0",
|
|
39
|
-
"@vaadin/a11y-base": "24.1.0-
|
|
40
|
-
"@vaadin/button": "24.1.0-
|
|
41
|
-
"@vaadin/component-base": "24.1.0-
|
|
42
|
-
"@vaadin/progress-bar": "24.1.0-
|
|
43
|
-
"@vaadin/vaadin-lumo-styles": "24.1.0-
|
|
44
|
-
"@vaadin/vaadin-material-styles": "24.1.0-
|
|
45
|
-
"@vaadin/vaadin-themable-mixin": "24.1.0-
|
|
39
|
+
"@vaadin/a11y-base": "24.1.0-alpha3",
|
|
40
|
+
"@vaadin/button": "24.1.0-alpha3",
|
|
41
|
+
"@vaadin/component-base": "24.1.0-alpha3",
|
|
42
|
+
"@vaadin/progress-bar": "24.1.0-alpha3",
|
|
43
|
+
"@vaadin/vaadin-lumo-styles": "24.1.0-alpha3",
|
|
44
|
+
"@vaadin/vaadin-material-styles": "24.1.0-alpha3",
|
|
45
|
+
"@vaadin/vaadin-themable-mixin": "24.1.0-alpha3",
|
|
46
46
|
"lit": "^2.0.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"web-types.json",
|
|
55
55
|
"web-types.lit.json"
|
|
56
56
|
],
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "077b4a8e8fff063b9eba4581af81f9e152cb852d"
|
|
58
58
|
}
|
package/src/vaadin-upload.js
CHANGED
|
@@ -492,6 +492,26 @@ class Upload extends ElementMixin(ThemableMixin(ControllerMixin(PolymerElement))
|
|
|
492
492
|
];
|
|
493
493
|
}
|
|
494
494
|
|
|
495
|
+
/** @private */
|
|
496
|
+
get __acceptRegexp() {
|
|
497
|
+
if (!this.accept) {
|
|
498
|
+
return null;
|
|
499
|
+
}
|
|
500
|
+
const processedTokens = this.accept.split(',').map((token) => {
|
|
501
|
+
let processedToken = token.trim();
|
|
502
|
+
// Escape regex operators common to mime types
|
|
503
|
+
processedToken = processedToken.replace(/[+.]/gu, '\\$&');
|
|
504
|
+
// Make extension patterns match the end of the file name
|
|
505
|
+
if (processedToken.startsWith('\\.')) {
|
|
506
|
+
processedToken = `.*${processedToken}$`;
|
|
507
|
+
}
|
|
508
|
+
// Handle star (*) wildcards
|
|
509
|
+
return processedToken.replace(/\/\*/gu, '/.*');
|
|
510
|
+
});
|
|
511
|
+
// Create accept regex
|
|
512
|
+
return new RegExp(`^(${processedTokens.join('|')})$`, 'iu');
|
|
513
|
+
}
|
|
514
|
+
|
|
495
515
|
/** @protected */
|
|
496
516
|
ready() {
|
|
497
517
|
super.ready();
|
|
@@ -879,12 +899,8 @@ class Upload extends ElementMixin(ThemableMixin(ControllerMixin(PolymerElement))
|
|
|
879
899
|
);
|
|
880
900
|
return;
|
|
881
901
|
}
|
|
882
|
-
const
|
|
883
|
-
|
|
884
|
-
const escapedAccept = this.accept.replace(/[+.]/gu, '\\$&');
|
|
885
|
-
// Create accept regex that can match comma separated patterns, star (*) wildcards
|
|
886
|
-
const re = new RegExp(`^(${escapedAccept.replace(/[, ]+/gu, '|').replace(/\/\*/gu, '/.*')})$`, 'iu');
|
|
887
|
-
if (this.accept && !(re.test(file.type) || re.test(fileExt))) {
|
|
902
|
+
const re = this.__acceptRegexp;
|
|
903
|
+
if (re && !(re.test(file.type) || re.test(file.name))) {
|
|
888
904
|
this.dispatchEvent(
|
|
889
905
|
new CustomEvent('file-reject', {
|
|
890
906
|
detail: { file, error: this.i18n.error.incorrectFileType },
|
package/web-types.json
CHANGED