File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -21,9 +21,18 @@ const MSG_DEVICE_ENUMERATION = 'deviceEnumeration';
2121
2222function canShare ( data ) {
2323 if ( typeof data !== 'object' ) return false ;
24- if ( ! ( 'url' in data ) && ! ( 'title' in data ) && ! ( 'text' in data ) ) return false ; // At least one of these is required
24+ // Make an in-place shallow copy of the data
25+ data = Object . assign ( { } , data ) ;
26+ // Delete undefined or null values
27+ for ( const key of [ 'url' , 'title' , 'text' , 'files' ] ) {
28+ if ( data [ key ] === undefined || data [ key ] === null ) {
29+ delete data [ key ] ;
30+ }
31+ }
32+ // After pruning we should still have at least one of these
33+ if ( ! ( 'url' in data ) && ! ( 'title' in data ) && ! ( 'text' in data ) ) return false ;
2534 if ( 'files' in data ) {
26- if ( ! Array . isArray ( data . files ) ) return false ;
35+ if ( ! ( Array . isArray ( data . files ) || data . files instanceof FileList ) ) return false ;
2736 if ( data . files . length > 0 ) return false ; // File sharing is not supported at the moment
2837 }
2938 if ( 'title' in data && typeof data . title !== 'string' ) return false ;
You can’t perform that action at this time.
0 commit comments