@vaadin/upload 23.3.8 → 23.3.10

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": "23.3.8",
3
+ "version": "23.3.10",
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.8",
40
- "@vaadin/component-base": "~23.3.8",
41
- "@vaadin/progress-bar": "~23.3.8",
42
- "@vaadin/vaadin-lumo-styles": "~23.3.8",
43
- "@vaadin/vaadin-material-styles": "~23.3.8",
44
- "@vaadin/vaadin-themable-mixin": "~23.3.8"
39
+ "@vaadin/button": "~23.3.10",
40
+ "@vaadin/component-base": "~23.3.10",
41
+ "@vaadin/progress-bar": "~23.3.10",
42
+ "@vaadin/vaadin-lumo-styles": "~23.3.10",
43
+ "@vaadin/vaadin-material-styles": "~23.3.10",
44
+ "@vaadin/vaadin-themable-mixin": "~23.3.10"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@esm-bundle/chai": "^4.3.4",
48
- "@vaadin/form-layout": "~23.3.8",
48
+ "@vaadin/form-layout": "~23.3.10",
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": "f3bfde4c881f9deb7d757faf4ab070f0596b0a09"
56
+ "gitHead": "aabe6a4f5fe0561e2aedf6dc1564479b281914b0"
57
57
  }
@@ -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 fileExt = file.name.match(/\.[^.]*$|$/)[0];
783
- // Escape regex operators common to mime types
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/upload",
4
- "version": "23.3.8",
4
+ "version": "23.3.10",
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": "23.3.8",
4
+ "version": "23.3.10",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {