File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed
Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -375,9 +375,20 @@ const TR = (i, row) => {
375375const copyShortUrl = ( shortLink , doCopy ) => {
376376 const fullLink = `${ SITE_URL } /${ shortLink } ` ;
377377 const linkElt = `<a href=${ fullLink } target="_blank">${ fullLink } </a>` ;
378- const copyPromise = doCopy // We want to use it only for the UI in some cases
379- ? navigator . clipboard . writeText ( fullLink )
380- : Promise . resolve ( ) ;
378+
379+ let copyPromise ;
380+ if (
381+ typeof ClipboardItem === "function" &&
382+ typeof navigator . clipboard === "object"
383+ ) {
384+ copyPromise = doCopy // We want to use it only for the UI in some cases
385+ ? navigator . clipboard . writeText ( fullLink )
386+ : Promise . resolve ( ) ;
387+ } else {
388+ copyPromise = Promise . reject (
389+ new Error ( "Unable to get access to clipboard." ) ,
390+ ) ;
391+ }
381392
382393 copyPromise
383394 . then ( ( ) =>
@@ -572,7 +583,10 @@ const submitForm = () => {
572583 } ;
573584
574585 let ok = false ;
575- if ( typeof ClipboardItem && navigator . clipboard . write ) {
586+ if (
587+ typeof ClipboardItem === typeof Function &&
588+ typeof navigator . clipboard === typeof Function
589+ ) {
576590 const copyPromise = new ClipboardItem ( {
577591 "text/plain" : fetch ( url , payload )
578592 . then ( ( res ) => {
You can’t perform that action at this time.
0 commit comments