@vaadin/upload 24.0.0 → 24.0.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/upload",
3
- "version": "24.0.0",
3
+ "version": "24.0.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -36,12 +36,12 @@
36
36
  ],
37
37
  "dependencies": {
38
38
  "@polymer/polymer": "^3.0.0",
39
- "@vaadin/button": "~24.0.0",
40
- "@vaadin/component-base": "~24.0.0",
41
- "@vaadin/progress-bar": "~24.0.0",
42
- "@vaadin/vaadin-lumo-styles": "~24.0.0",
43
- "@vaadin/vaadin-material-styles": "~24.0.0",
44
- "@vaadin/vaadin-themable-mixin": "~24.0.0",
39
+ "@vaadin/button": "~24.0.2",
40
+ "@vaadin/component-base": "~24.0.2",
41
+ "@vaadin/progress-bar": "~24.0.2",
42
+ "@vaadin/vaadin-lumo-styles": "~24.0.2",
43
+ "@vaadin/vaadin-material-styles": "~24.0.2",
44
+ "@vaadin/vaadin-themable-mixin": "~24.0.2",
45
45
  "lit": "^2.0.0"
46
46
  },
47
47
  "devDependencies": {
@@ -53,5 +53,5 @@
53
53
  "web-types.json",
54
54
  "web-types.lit.json"
55
55
  ],
56
- "gitHead": "b0cf651bb624d74b78a42b3e3ea889b2e401daec"
56
+ "gitHead": "b349227fa277573b79d94eb0d94c1556b79c55e8"
57
57
  }
@@ -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 fileExt = file.name.match(/\.[^.]*$|$/u)[0];
883
- // Escape regex operators common to mime types
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/upload",
4
- "version": "24.0.0",
4
+ "version": "24.0.2",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/upload",
4
- "version": "24.0.0",
4
+ "version": "24.0.2",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {